Click to See Complete Forum and Search --> : checking to see if a file exists in Word... RESOLVED!
apeface76
Jul 19th, 2005, 04:49 PM
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!
StevenHickerson
Jul 19th, 2005, 10:10 PM
The easiest way I find to check for files existing without the old error trapping way is a file system object.
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.
apeface76
Jul 20th, 2005, 08:28 AM
fantastic. thanks for the help!
manavo11
Jul 20th, 2005, 08:30 AM
Another option is the PathFileExists API.
Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.