Option Explicit Public Function FileExists(fPath As String) As Boolean Dim retval As String Dim fName As String Dim i As Integer On Error GoTo FileExistsError For i = 1 To Len(fPath) If Mid(fPath, Len(fPath) - i, 1) = "\" Then fName = Right(fPath, i) Exit For End If Next i 'does the file exist? retval = Dir$(fPath) If retval = fName Then 'the file exists, return true FileExists = True Else FileExists = False End If Exit Function FileExistsError: 'if an error occurs, the file doesnot exist FileExists = False Exit Function End Function