Does File Exist Test?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can you verify that a file exists? Is there a function that you can feed
the path and file name as arguments and it will tell you if the file exists
(that is, the path and file name are accurate?

Thank you.

Ross
 
Yes....oddly enough it is called FileExists, but it requires that you
instantiate the FileSystemObject, i.e.,

Dim fso as variant
Dim blnResult as Boolean

Set fso = CreateObject("Scripting.FileSystemObject")

blnResult = fso.FileExists("file spec here")

Another (simpler) way would be to use the Dir function, i.e.,

Dim blnResult As Boolean

blnResult = Len(Dir("file spec here"))>0
 
Thank you Paul!

Ross

Paul Overway said:
Yes....oddly enough it is called FileExists, but it requires that you
instantiate the FileSystemObject, i.e.,

Dim fso as variant
Dim blnResult as Boolean

Set fso = CreateObject("Scripting.FileSystemObject")

blnResult = fso.FileExists("file spec here")

Another (simpler) way would be to use the Dir function, i.e.,

Dim blnResult As Boolean

blnResult = Len(Dir("file spec here"))>0
 
Yes, I don't remember the exact syntax. But you're looking to use the
FileSystemObject and its various methods.
 
Or the Dir function, which means you don't have the overhead of
instantiating FSO.
 
Back
Top