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!

Checking valid filepaths

Status
Not open for further replies.

paulo33

Technical User
Oct 31, 2002
15
0
0
AU
I have some code in VBA that looks for a file, and then opens it.

Does anybody know of a way to check if the file exists/filepath is valid, before trying to open the file, so as to not produce an error?

thanks

 
paulo33,

This function is from John Walkenbach's book "Power Programming With VBA":

Code:
Private Function FileExists(fname) as Boolean
Dim x as String

  x = Dir(fname)
  If x <> &quot;&quot; Then
    FileExists = True
  Else
    FileExists = False
  End If
End Function

HTH
Mike
 
Paulo I could use some help with the code that goes out and finds the folder, I also have a database that I need the onClick procedure to find a folder, I need some example code. If you could help I would appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top