解释VBA中的编码

时间:2013-02-14 06:57:37

标签: vba

    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

1 个答案:

答案 0 :(得分:2)

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

但在我看来,你应该自己学习,不要只是让我们向你解释。