使用 Microsoft 登录
登录或创建帐户。
你好,
使用其他帐户。
你有多个帐户
选择要登录的帐户。

适用于

Application 对象

返回表示字段对话框的单个实例的 FileDialog 对象。

表达式.FileDialog(dialogType)

表达式 必需。 返回“适用范围”列表中的对象之一的表达式。

dialogType    需要 MsoFileDialogType。 文件对话框的类型。

MsoFileDialogType 可以为以下任一 MsoFileDialogType 常量。

msoFileDialogFilePicker

msoFileDialogFolderPicker

msoFileDialogOpen Microsoft Access 中不支持。

msoFileDialogSaveAs Microsoft Access 中不支持。

备注

Microsoft Office Access 2007 中不支持 msoFileDialogOpenmsoFileDialogSaveAs 常量。

示例

此示例说明了如何使用 FileDialog 对象来显示允许用户选择一个或多个文件的对话框。 所选的文件随后将添加到名为 FileList 的列表框中。

Private Sub cmdFileDialog_Click()
' Requires reference to Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
' Clear listbox contents.
Me.FileList.RowSource = ""
' Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow user to make multiple selections in dialog box
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Please select one or more files"
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.ACCDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub

需要更多帮助?

需要更多选项?

了解订阅权益、浏览培训课程、了解如何保护设备等。

社区可帮助你提出和回答问题、提供反馈,并听取经验丰富专家的意见。

此信息是否有帮助?

你对语言质量的满意程度如何?
哪些因素影响了你的体验?
按“提交”即表示你的反馈将用于改进 Microsoft 产品和服务。 你的 IT 管理员将能够收集此数据。 隐私声明。

谢谢您的反馈!

×