This is a function to verify if your workbook exists in the defined location, so that before you can open your workbook, VBA codes can open your desired workbook properly.
It will return “TRUE” if the workbook is located in the desired location.
It will return “FALSE” if the workbook doesn’t exist in the desired location.
Function DoesWorkBookExist(ByVal wbPath As String, ByVal WBName As String) As Boolean
Dim i As Integer
Dim FileCheck As String
FileCheck = wbPath & “\” & WBName
If Dir(FileCheck) <> “” Then
‘MsgBox (“Workbook – ” & wbName & ” exists”)
DoesWorkBookExist = True
‘MsgBox (“Workbook – ” & wbName & ” doesn’t exist”)
DoesWorkBookExist = False