-3
    Dim fdg As FileDialog
    Set fdg = Application.FileDialog(msoFileDialogFilePicker)
    fdg.Filters.Add "Text Documents", "*.dat", 1

    While fdg.Filters.Count > 1
        fdg.Filters.Delete 2
    Wend

    With fdg
        .AllowMultiSelect = False
        .InitialFileName = "c:\"
        .InitialView = msoFileDialogViewDetails
        If .Show = -1 Then
            For Each vrtSelectedItem In .SelectedItems    'onby be 1
                strSelectedFile = vrtSelectedItem
            Next vrtSelectedItem
        Else
        End If
    End With
    Set fd = Nothing
    If Not IsEmpty(strSelectedFile) Then
        Filenametxt = strSelectedFile
    End If
4

1 回答 1

2

这段代码似乎允许用户打开*.dat文件并通过所选文件的路径分配Filenametxt变量。

但在我看来,您应该自己学习,而不仅仅是要求我们向您解释。

于 2013-02-14T07:05:08.337 回答