Finding Excel File. Loop, Files
Posted: 27 Jun 2019, 14:41
Hi Everyone,
I built a COM OBJ script that pulls data value from excel. And it works.
I also have a script that finds a folder directory based on the first characters. It also works!
So now I want to combine them both to make a super mega ultra-powered bundle of scripting that will find my excel file in the database and extract its information.
I won't bore you with the first two scripts.
But here is what I got. It never finds the file, and the second msgbox always returns blank.
Here are the "rules"
My Database is sorted in this way.
Here is an example of what I might put into the user input
State code and project Id are always constant. Business, name, and address ID sometimes is shorter. Because our Google drive doesn't allow names to be too long or it crashes. So most likely Business name is shortened in its file and/or folder.
All projects have an excel sheet attached to it. Here's an example of the path I would be trying to find:
if I can find the file, then it should be easy for me to use it as a variable, and feed the full path into the second excel script.
Disclaimer: I'm a newbie. 2nd month. doing AHK. So it's possible very obvious things are completely missed in here. Feel free to point them out. I will absorb all constructive information thrown my way.
Ice cream for everyone who pitches in!
I built a COM OBJ script that pulls data value from excel. And it works.
I also have a script that finds a folder directory based on the first characters. It also works!
So now I want to combine them both to make a super mega ultra-powered bundle of scripting that will find my excel file in the database and extract its information.
I won't bore you with the first two scripts.
But here is what I got. It never finds the file, and the second msgbox always returns blank.
Code: Select all
!q::
inputbox, userinput, Enter Full Project ID, , ,300 ,100
; If the user pressed cancel or the string is too short
if (ErrorLevel || StrLen(userinput) = 0)
return
FoundFile := ""
Loop, Files, % "I:\My Drive\Webcam\Webcam - Projects\" SubStr(userinput, 1, 4) "\" SubStr(userinput, 1, 15) "*" "\"SubStr(userinput, 1, 15) "*".xlsl , FD
{
FoundFile := A_LoopFileFullPath
break
}
if (FoundFile != "")
Run, % FoundFile
Else
msgbox, I didn't find the file.
;IfExist, % "I:\My Drive\Webcam\Webcam - Projects\" SubStr(userinput, 1, 4) "\" SubStr(userinput, 1, 15) "*" "\" SubStr(userinput, 1, 15) "*".xlsl
msgbox, %foundfile%
return
My Database is sorted in this way.
Code: Select all
4 Digit State Code - 5 Digit project ID - company name - Business Name - address.
Code: Select all
TX15 - 78558 - Big business corporation - the business of typing, inc - 9506 Auto hotkey avenue
All projects have an excel sheet attached to it. Here's an example of the path I would be trying to find:
Code: Select all
I:\My Drive\Webcam\Webcam - Projects\TX15\TX15 - 78558 - Big business corporation - business of typing - 9506 Auto hotkey avenue\TX15 - 78558 - Big business corporation - the business of typing.xlsl
Disclaimer: I'm a newbie. 2nd month. doing AHK. So it's possible very obvious things are completely missed in here. Feel free to point them out. I will absorb all constructive information thrown my way.
Ice cream for everyone who pitches in!