function to seach directory for file location

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

Guest

i have to keep individual files on each piece of equipment.
i am looking for a way to search a directory to see if the file exists.
 
i have to keep individual files on each piece of equipment.
i am looking for a way to search a directory to see if the file exists.

I usually use the VBA command

Dir(Myfilename)

This returns a Null "" string if MyFilename does not exist so
something like the following will alert you. If you need to check for
many files as your Q. suggests then you'd need to build this into a
loop and change the Myfilename variable each time through the loop.

Sub FileExists
If Dir("c:\Myfilename") = "" Then
MsgBox "File missing"
End If
End Sub

HTH
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top