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
答案 0 :(得分:2)
这段代码似乎允许用户打开*.dat
文件,并通过所选文件的路径分配Filenametxt
变量。
但在我看来,你应该自己学习,不要只是让我们向你解释。