'*******************************************************************************
'** Function: GetFileName
'** Parameters:
'** FilePath (String) - the full file path of the file
'** Returns: The file name of for the given file path
'*******************************************************************************
Public Function GetFileName(FilePath As String) As String
On Error GoTo GetFileNameError
Dim slashLocation As Integer
If Len(FilePath) = 0 Then
GetFileName = ""
Exit Function
End If
'Find the last \ in the path
slashLocation = InStrRev(FilePath, "\")
GetFileName = Mid$(FilePath, slashLocation + 1, Len(FilePath) + 1 - slashLocation)
Exit Function
GetFileNameError:
GetFileName = ""
MsgBox "Error #" & Err.Number & vbCrLf & Err.Description, vbExclamation, "Error"
End Function