You are passing the full path to your function, so you can get the path from that. For example:
Public Function Filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, ""))
Filename = Mid(strPath, InStrRev(strPath, "") + 1)
End Function
Called by, say:
sFile = Filename(f.SelectedItems(i), sPath)
MsgBox sPath & "---" & sFile
In full
Private Sub Command7_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = Filename(f.SelectedItems(i), sPath)
MsgBox sPath & "---" & sFile
Next
End If
End Sub
Public Function Filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, ""))
Filename = Mid(strPath, InStrRev(strPath, "") + 1)
End Function
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…