FileDialog Property
Returns a FileDialog object that represents a single instance of a file dialog box.
expression.FileDialog(DialogType)
expression Required. An expression that returns an Application object.
DialogType Required MsoFileDialogType. The type of dialog box to open.
MsoFileDialogType can be one of these MsoFileDialogType constants. |
msoFileDialogFilePicker |
msoFileDialogFolderPicker |
msoFileDialogOpen |
msoFileDialogSaveAs |
Example
The following example displays the Save As dialog box.
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
The following example displays the Open dialog box, and allows the user to open multiple files at the same time.
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
The following example displays the Open dialog box, and allows the user to open multiple files at the same time. If the documents are HTML files, they are opened in 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