hi --
I'm attempting to write a script in Word in which the script checks a specific folder for a specifically named file. If it's not there, it then looks for the next file.
Not sure what to do here - any advice much appreciated. Thanks!
Printable View
hi --
I'm attempting to write a script in Word in which the script checks a specific folder for a specifically named file. If it's not there, it then looks for the next file.
Not sure what to do here - any advice much appreciated. Thanks!
The easiest way I find to check for files existing without the old error trapping way is a file system object.
VB Code:
Set FSO = CreateObject("Scripting.FileSystemObject") If FSO.FileExists(FileName) Then 'Conditions if true Else 'Not true End If
If someone could I'm not totally sure about the createobject, can't remember if its Scripting. or something else... usually just reference it in VB but know you can do it this way to because I had to do it once on an asp page.
fantastic. thanks for the help!
Another option is the PathFileExists API.
VB Code:
Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long