Test If File Exists

Test If File Exists

The test with vbDirectory is to prevent a foldername to be considered as a file. FileLen is used as an extra check to see if anything is actually found at that location.

Public Function FileExists(strFileFullPath As StringAs Boolean
Dim lSize  As Long
    On Error GoTo HandleError
    lSize = -1
    If GetAttr(strFileFullPath) And vbDirectory Then GoTo HandleExit
    lSize = FileLen(strFileFullPath)
    FileExists = lSize > -1
HandleExit:
    Exit Function
HandleError:
    Resume Next
End Function