Private Sub Form_Load() MsgBox GetFileName("c:\myfiles\111\222\3333\4444\myfile.txt") End Sub Function GetFileName(FileName As String) As String 'Parses the filename out of a directory string
Dim i As Integer
On Error Resume Next
For i = Len(FileName) To 1 Step -1 If Mid(FileName, i, 1) = "\" Then Exit For End If Next
MsgBox GetFileName("c:\myfiles\111\222\3333\4444\myfile.txt")
End Sub
Function GetFileName(FileName As String) As String
'Parses the filename out of a directory string
Dim i As Integer
On Error Resume Next
For i = Len(FileName) To 1 Step -1
If Mid(FileName, i, 1) = "\" Then
Exit For
End If
Next
GetFileName = Mid(FileName, i + 1)End Function