Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA File Exist commands? 1

Status
Not open for further replies.

bujin

MIS
Oct 2, 2000
144
0
0
GB
Is there such a thing? If not, how do I find out if a file exists using Visual Basic for Applications (in Excel)?
 
Never mind, I got it! I was thinking of Delphi (I think). Just use the Dir() command.
 
You can also use Application.FileSearch, it depends which one you think is easier.
 
Well would you look at that! That's simplified the task ten-fold! :)

Thx Dark_Sun!
 
Dir is the vb way to test if a file or directory exists.

HTH
 
Or use Scripting.FileSystemObject.

i.e.

Code:
Dim FSO As FileSystemObject

Set FSO = New FileSystemObject

If FSO.FileExists(&quot;<path to file&quot;) Then
     ' Code on existence of file.
End If

HTH John Whyte
jwhyte@skipton.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top