Application.SetCustomMenus method (Visio)
Replaces the current built-in or custom menus of an application or document.
Note
Starting with Visio 2010, the Microsoft Office Fluent user interface (UI) replaced the previous system of layered menus, toolbars, and task panes. VBA objects and members that you used to customize the user interface in previous versions of Visio are still available in Visio, but they function differently.
Syntax
expression.SetCustomMenus (MenusObject)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
MenusObject | Required | [IVUIOBJECT] | An expression that returns a UIObject object that represents the new custom menus. |
Return value
Nothing
Remarks
If the UIObject object was created in a separate process by using the CreateObject procedure instead of getting the appropriate property of an Application or Document object, the SetCustomMenus method returns an error.
Example
This Microsoft Visual Basic for Applications (VBA) macro shows how to add a menu and menu item to the user interface, and then replace the built-in menu set with the custom set.
To restore the Microsoft Visio built-in user interface after you run this macro, call the ThisDocument.ClearCustomMenus method.
Public Sub SetCustomMenus_Example()
Dim vsoUIObject As Visio.UIObject
Dim vsoMenuSets As Visio.MenuSets
Dim vsoMenuSet As Visio.MenuSet
Dim vsoMenus As Visio.Menus
Dim vsoMenu As Visio.Menu
Dim vsoMenuItems As Visio.MenuItems
Dim vsoMenuItem As Visio.MenuItem
'Get a UI object that represents the Microsoft Visio built-in menus.
Set vsoUIObject = Visio.Application.BuiltInMenus
'Get the MenuSets collection.
Set vsoMenuSets = vsoUIObject.MenuSets
'Get the drawing window menu set.
Set vsoMenuSet = vsoMenuSets.ItemAtID(visUIObjSetDrawing)
'Get the Menus collection.
Set vsoMenus = vsoMenuSet.Menus
'Add a Demo menu.
Set vsoMenu = vsoMenus.AddAt(1)
vsoMenu.Caption = "Demo"
'Get the MenuItems collection.
Set vsoMenuItems = vsoMenu.MenuItems
'Add a menu item to the new Demo menu.
Set vsoMenuItem = vsoMenuItems.Add
'Set the properties for the new menu item.
vsoMenuItem.Caption = "&Hello"
vsoMenuItem.AddOnName = "MsgBox ""Hello"""
'Tell Visio to use the new UI when the document is active.
ThisDocument.SetCustomMenus vsoUIObject
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기