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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check to see if a file exists

Status
Not open for further replies.

chiefvj

Technical User
Feb 4, 2005
73
US
Can anyone help with a thread to how I can check to see if a file exists. I have a back-end database and sometimes the server crashes. I need to check to see if my application can link to the tables and send a custom message notifying the user that the application cannot link to the tables.
thx in advance..
 
try this...

Sub FileExists()
Dim fso
Dim file As String
file = "C:\Test.xls" ' change to match the file w/Path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(file) Then
MsgBox file & " was not located.", vbInformation, "File Not Found"
Else
MsgBox file & " has been located.", vbInformation, "File Found"
End If
End Sub
 
Have a look at the Dir function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top