Code: Select all
Option Explicit
Function FileExists(strFullName As String) As Boolean
FileExists = Not (Dir(strFullName) = "")
End Function
Sub A01_FileChecker()
Dim Msg As String, strPath1 As String, strPath2 As String, strFile As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This is the File Checker which ensures that all the required files are in the current folder (ThisWorkbook.Path)
strPath1 = ThisWorkbook.Path & "\"
strPath2 = strPath1 & "Reports" & "\"
Msg = vbCrLf & "ERROR"
Msg = Msg & vbCrLf & vbCrLf & "Ensure that the Bat File has run successfully, and that all source files are available."
Msg = Msg & vbCrLf & vbCrLf & "The following file is unavailable, and should be created before continuing."
Msg = Msg & vbCrLf & vbCrLf
strFile = "File1.xls"
If FileExists(strPath1 & strFile) = False Then
MsgBox Msg & strPath1 & strFile & vbCrLf & vbCrLf, vbExclamation
Exit Sub
End If
'more of the same
strFile = "File36.xls"
If FileExists(strPath2 & strFile) = False Then
MsgBox Msg & strPath2 & strFile & vbCrLf & vbCrLf, vbExclamation
Exit Sub
End If
'more of the same
End Sub