返回 FileDialog 对象,该对象代表文件对话框的一个实例。
expression.FileDialog(DialogType)
expression 必选。返回“应用于”列表中的对象之一的表达式。
DialogType 必选,MsoFileDialogType 常数。要打开的对话框类型。
MsoFileDialogType 可以是下列这些 MsoFileDialogType 常数之一。 |
msoFileDialogFilePicker |
msoFileDialogFolderPicker |
msoFileDialogOpen |
msoFileDialogSaveAs |
下列示例将应用程序的对话框类型设置为“另存为”对话框,并显示新对话框。
Sub ShowSaveAsDialog()
'Display the Save As dialog box
Dim dlgSaveAs As FileDialog
'Set the dialog type
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
'Display the dialog
dlgSaveAs.Show
End Sub
下列示例显示“打开”对话框,并允许用户同时打开多个文件。
Sub ShowOpenDialog()
'Display the Open dialog box
Dim dlgOpen As FileDialog
'Set the dialog box type to Open
Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
'Display the dialog box
With dlgOpen
.AllowMultiSelect = True
.Show
End With
End Sub
下列示例显示“打开”对话框,并允许用户同时打开多个文件。如果文档为 HTML 文件,则将在 Microsoft FrontPage 中打开。
Sub ShowOpenDialog()
'Display the Open dialog box
Dim dlgOpen As FileDialog
'Set the dialog box type to Open
Dim i as Integer
Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
'Display the dialog box
With dlgOpen
.AllowMultiSelect = True
.Show
End With
For i = 1 To dlgOpen.SelectedItems.Count
If Right(dlgOpen.SelectedItems(i), 3) = "htm" Then
ActiveWebWindow.PageWindows.Add dlgOpen.SelectedItems(i)
End If
Next
End Sub