|
Function GetFileName(TitleText As String, Filter As String, FilterText As String, ByVal DialogType As Integer, Optional ByVal FilePath) As String
'参数DialogType说明:
'1.“打开”对话框
'2.“另存为”对话框(这个项不好用,所以加了出错处理为 Resume Next)
'3.“文件选取器”对话框
'4.“文件夹选取器”对话框
'例:AA = GetFileName("打开", "*.ini;*.txt", "配置文件", 1)
On Error Resume Next
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(DialogType)
With dlgOpen
.title = TitleText
.Filters.Clear
.Filters.ADD FilterText, Filter
.AllowMultiSelect = False
If IsMissing(FilePath) Then
.InitialFileName = a(10)
Else
.InitialFileName = FilePath
End If
.Show
End With
If dlgOpen.SelectedItems.Count > 0 Then
GetFileName = dlgOpen.SelectedItems(1)
Else
GetFileName = ""
End If
Set dlgOpen = Nothing
End Function
'4.“文件夹选取器”对话框
'例:AA = GetFileName("打开", "*.ini;*.txt", "配置文件", 1) 这个格式是放在一起了
怎么改成:
*.ini
*.txt
*.PDF
这样?
|
|