共用方式為


Office) (FileDialog.DialogType 屬性

會取得 MsoFileDialogType 常 數,代表 FileDialog 物件設定為顯示的檔對話方塊類型。 唯讀。

語法

運算式DialogType

expression 代表 FileDialog 物件的變數。

範例

下列範例會採用未知類型的 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

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應