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.

Advertisements

1 Comment »

  1. Beautiful!!!

    Comment by Rafael Dvl — March 27, 2012 @ 4:40 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: