Wikipedia

Search results

Thursday 11 August 2016

Check if a file exists


Sub FileExists()
Dim fso
Dim file As String

file = "C:\Test.xls"
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

No comments:

Post a Comment