Application.CustomMenusFile 属性 (Visio)

获取或设置定义 Application 对象的自定义菜单和快捷键的文件的名称。 读/写。

注意

从 Visio 2010 开始,Microsoft Office Fluent 用户界面 (UI) 替换了以前的分层菜单、工具栏和任务窗格系统。 用于在以前版本的 Visio 中自定义用户界面的 VBA 对象和成员在 Visio 中仍可用,但它们的功能不同。

语法

表达式CustomMenusFile

expression:表示 Application 对象的变量。

返回值

String

备注

如果对象没有使用自定义菜单,则 CustomMenusFile 属性返回 Nothing

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何获取您的文档的当前活动 UI 而无需替换应用程序级的自定义 UI。 该宏还将现有的任何自定义菜单保存到某个文件,并指定当前文档使用这些菜单。 您必须编写其他代码来添加您的自定义 UI 项。

警告

此宏使用 VBA 关键字 Kill 来删除磁盘上的某个文件。 请谨慎使用此关键字,因为在运行 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。