會取得或設定針對 Application 物件定義自訂功能表和快速鍵的檔案名稱。 讀取/寫入。
注意事項
從 Visio 2010 開始,Microsoft Office Fluent 使用者介面 (UI) 取代先前的多層式功能表、工具列和工作窗格系統。 您在舊版 Visio 中用來自訂使用者介面的 VBA 物件和成員在 Visio 中仍然可用,但功能不同。
語法
運算式。CustomMenusFile
expression 代表 Application 物件的變數。
傳回值
字串
註解
如果物件沒有使用自訂功能表,CustomMenusFile 屬性會傳回 Nothing。
範例
這個Microsoft Visual Basic for Applications (VBA) 巨集 示範如何在不取代應用程式層級自訂 UI 的情況下,取得文件目前使用中的 UI。 它還會將任何現有的自訂功能表儲存至檔案,並指定目前文件使用這些功能表。 您必須撰寫其他程式碼才能新增自訂 UI 項目。
注意
這個巨集會使用 VBA 關鍵字 Kill 刪除磁碟上的檔案。 請謹慎使用此關鍵字,因為執行之後您無法復原 [刪除 ] 命令,而且您不會收到事先的警告訊息。
Sub CustomMenusFile_Example()
Dim vsoUIObject As Visio.UIObject
Dim strPath As String
'Check whether there are custom menus bound to the document.
If ThisDocument.CustomMenus Is Nothing Then
'If not, check whether there are custom menus bound to the application.
If Visio.Application.CustomMenus Is Nothing Then
'If not, use the Visio built-in menus.
Set vsoUIObject = Visio.Application.BuiltInMenus
MsgBox "Using Built-In Menus", 0
Else
'If there are existing Visio custom menus, use them.
Set vsoUIObject = Visio.Application.CustomMenus
'Save these custom menus to a file.
strPath = Visio.Application.Path & "\CustomUI.vsu"
vsoUIObject.SaveToFile (strPath)
'Set the document to use the existing custom UI.
ThisDocument.CustomMenusFile = strPath
'Get this document's UIObject object.
Set vsoUIObject = ThisDocument.CustomMenus
'Delete the newly created temp file.
Kill Visio.Application.Path & "\CustomUI.vsu"
ThisDocument.ClearCustomMenus
MsgBox "Using Custom Menus", 0
End If
Else
'Use the existing custom menus.
Set vsoUIObject = ThisDocument.CustomMenus
End If
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。