Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

適用對象

應用程式物件

傳回代表單一檔案對話方塊執行個體的 FileDialog 物件。

expression.FileDialog(dialogType)

運算式 必要。 傳回 [套用至] 清單中其中一個對象的表達式。

dialogType    必要 MsoFileDialogType。 檔案對話方塊類型。

MsoFileDialogType 可為下列其中一種 MsoFileDialogType 常數。

msoFileDialogFilePicker

msoFileDialogFolderPicker

msoFileDialogOpen Microsoft Access 不支援。

msoFileDialogSaveAs Microsoft Access 不支援。

備註

msoFileDialogOpenmsoFileDialogSaveAs 在 Microsoft Office Access 2007 中不支援。

範例

此範例說明如何使用 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

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×