Nilesh’s Weblog

August 4, 2008

VBA File Exists

Filed under: Microsoft Excel — Tags: , , — deshnilesh @ 2:36 pm

Couple of times I was expected to execute a code only if a particular file exists. I use to create a object of FSO and check it. However recently(was late for me though) I discovered and simple way of doing it –

If Dir("C:Testfile.xls") <> "" then
'file exists
else
'file does not exist
End if

Hope this is useful for someone.

Blog at WordPress.com.