ms访问从FileDialog中选择的文件名

Mah*_*yar 6 ms-access vba

这是我的代码,我想知道如何获取所选文件的名称

Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
    For i = 1 To f.SelectedItems.Count
        MsgBox f.SelectedItems(i)
    Next
EndIf
Run Code Online (Sandbox Code Playgroud)

Sid*_*out 10

你的意思是这样的?

Sub Sample()
    Dim f As Object

    Set f = Application.FileDialog(3)

    f.AllowMultiSelect = True

    If f.Show Then
        For i = 1 To f.SelectedItems.Count
            MsgBox Filename(f.SelectedItems(i))
        Next
    End If
End Sub

Public Function Filename(ByVal strPath As String) As String
    If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
        Filename = Filename(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
    End If
End Function
Run Code Online (Sandbox Code Playgroud)