Excel VBA - How to Check if File Exists (Dir function)

Опубликовано: 08 Октябрь 2024
на канале: InAnOffice
14,887
71

Excel VBA Check to see if a file exists using Dir function

The code used in this video:

Sub CheckIfFileExists()
Dim MyFile As String
MyFile = "C:\Reports\24 Nov 2015.xlsx"

If Dir(MyFile) "" Then
MsgBox "File exists"
Else
MsgBox "File does not exist"
End If

End Sub