DialogType Property

MsoFileDialogType

MsoFileDialogType can be one of these MsoFileDialogType constants.
msoFileDialogFilePicker
msoFileDialogFolderPicker
msoFileDialogOpen
msoFileDialogSaveAs

expression.DialogType

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

The following example takes a FileDialog object of an unknown type and runs the Execute method if it is a SaveAs dialog box or an Open dialog box.

Sub DisplayAndExecuteFileDialog(ByRef fd As FileDialog)

    'Use a With...End With block to reference the FileDialog object.
    With fd
        'If the user presses the action button...
        If .Show = -1 Then

            'Use the DialogType property to determine whether to
            'use the Execute method.
            Select Case .DialogType
                Case msoFileDialogOpen, msoFileDialogSaveAs: .Execute
                'Do nothing otherwise.
                Case Else
            End Select
        'If the user presses Cancel...
        Else
        End If
    End With

End Sub

Applies to | FileDialog Object