目录

DialogType 属性

优质
小牛编辑
123浏览
2023-12-01

全部显示

返回一个MsoFileDialogType 常量,表示 FileDialog 对象显示的文件对话框类型。只读。

MsoFileDialogType 可以为下列 MsoFileDialogType 常量之一。msoFileDialogFilePickermsoFileDialogFolderPickermsoFileDialogOpenmsoFileDialogSaveAs

expression.DialogType

expression 必需。该表达式返回“应用于”列表中的对象之一。

示例

本示例将 FileDialog 对象视为未知类型,并运行 Execute 方法判断是“另存为”还是“打开”对话框。

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