Im after a small piece of code that will check a directory for a certain file and advise whether it exiss or not.
Thank you in advance for anyhelp you can provide.
Im after a small piece of code that will check a directory for a certain file and advise whether it exiss or not.
Thank you in advance for anyhelp you can provide.
Dir returns an empty string if no file is found matching the 'search' pattern.![]()
Please Login or Register to view this content.
Good afternoon ceemo
The example below will check whether your C:\ drive contains a file called filename.xls. In the unlikely event that it does, "TRUE" will be returned in a msgbox, otherwise (and probably) "FALSE" will be returned.
Sub DoesFileExist()
Set MyFile = CreateObject("Scripting.FileSystemObject")
MsgBox MyFile.FileExists("c:\filename.xls")
End Sub
HTH
DominicB
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks