This is a function to verify if the desired file or directory exist, it is also important to get the status before any file operation being performed.
If the file or directory exists, it will return TRUE, otherwise, will return FALSE.
Function FileOrDirExists(ByVal PathName As String) As Boolean
‘Macro Purpose: Function returns TRUE if the specified file
‘ or folder exists, false if not.
‘PathName : Supports Windows mapped drives or UNC
‘ : Supports Macintosh paths
‘File usage : Provide full file path and extension
‘Folder usage : Provide full folder path
‘ Accepts with/without trailing “\” (Windows)
‘ Accepts with/without trailing “:” (Macintosh)
Dim iTemp As Integer
‘Ignore errors to allow for error evaluation
On Error Resume Next
iTemp = GetAttr(PathName)
‘Check if error exists and set response appropriately
Select Case Err.Number
Case Is = 0
FileOrDirExists = True
FileOrDirExists = False
‘Resume error checking
On Error GoTo 0