Отнася се за
Обект Application |
Връща обект FileDialog, който представлява единичен екземпляр на диалогов прозорец на файл.
израз.FileDialog(dialogType)
израз Задължително. Израз, който връща един от обектите в списъка "Отнася се за".
dialogType Задължителен е MsoFileDialogType. Тип на диалоговия прозорец на файла.
MsoFileDialogType може да е една от тези константи на MsoFileDialogType. |
msoFileDialogFilePicker |
msoFileDialogFolderPicker |
msoFileDialogOpen Не се поддържа в Microsoft Access. |
msoFileDialogSaveAs Не се поддържа в Microsoft Access. |
Забележки
Константите msoFileDialogOpen и msoFileDialogSaveAs не се поддържат в 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