적용 대상
응용 프로그램 개체 |
파일 대화 상자의 단일 인스턴스를 나타내는 FileDialog 개체를 반환합니다.
expression.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