File selector, How do i specify filetype?

前端 未结 1 1453
面向向阳花
面向向阳花 2021-01-05 18:06

I have the following code that opens a file selector and lets the user pick a file.

Sub SelectFiles(ByRef test As String)

    Dim iFileSelect As FileDialog
         


        
相关标签:
1条回答
  • 2021-01-05 18:38
    Sub Main()
        Dim test As String
        SelectFiles test
        Debug.Print test
    End Sub
    
    Sub SelectFiles(ByRef test As String)
    
        Dim iFileSelect As FileDialog
        Set iFileSelect = Application.FileDialog(msoFileDialogOpen)
        With iFileSelect
            .AllowMultiSelect = True
            .Title = "Select XML Files"
            .Filters.Clear
            .Filters.Add "Extensible Markup Language Files", "*.xml"
            .InitialView = msoFileDialogViewDetails
            If .Show = -1 Then
                Dim vrtSelectedItem
                For Each vrtSelectedItem In iFileSelect.SelectedItems
                    test = vrtSelectedItem
                Next vrtSelectedItem
            End If
        End With
        Set iFileSelect = Nothing
    End Sub
    
    0 讨论(0)
提交回复
热议问题