Checking if a file exists

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

Guest

Hey all

How in VBA would you check to see if a file exists to determine whether to proceed or not

Thanks
ari
 
Ari,

Try something like:

If Dir("PathAndFileName.ext") <> "" Then
'code to do what you want
Else
msgbox "File not found"
End If

Dir will return the full apth and file name if the file exists, or an empty
string if it does not.

HTH,
Nikos
 
Look at the Dir function. This will allow you to check a directory fo
a file or a set of files that meet a criteria. If the Dir functio
returns a zero length string if the file does not exist. There ar
good examples in the Access help files
 
Back
Top