Gets the file name from the path.
Sub GetFileName()
Dim stPathSep As String
Dim fileLength As Integer
Dim i As Integer
Dim stFullName As String
stFullName = "C:\asdf.xls"
stPathSep = Application.PathSeparator
fileLength = Len(stFullName)
For i = fileLength To 1 Step -1
If Mid(stFullName, i, 1) = stPathSep Then Exit For
Debug.Print Right(stFullName, fileLength - i + 1)
Next i
End Sub
Related examples in the same category