S
Stef
Hi,
I create a VBA menu, inside a VSS file.
In my document, the menu is all the time in gray, impossible to
activate. Following my code, thanks to help me.
Dim AUIObject As Visio.UIObject
Dim AMenuSet As Visio.MenuSet
Dim AMenuItems As Visio.MenuItems
Dim AMenuItem As Visio.MenuItem
Dim AMenu As Visio.Menu
'Get the UI object for the copy of the MSOffice Menus
Set AUIObject = Visio.Documents.Application.BuiltInMenus
'(visMenuMSOffice)
'Get the Drawing Window Menusets
'NOTE: Use ItemAtID to get the Menuset.
'Using uiObj.MenuSets(visUIObjSetDrawing) will not work.
Set AMenuSet = AUIObject.MenuSets.ItemAtID(visUIObjSetDrawing)
Set AMenu = AMenuSet.Menus.Add
AMenu.Caption = "MyMenu"
'Get the MenuItems collection
Set AMenuItems = AMenu.MenuItems
'Add a new button in the first position
Set AMenuItem = AMenuItems.AddAt(0)
'Set the properties for the new Menu button
AMenuItem.CmdNum = 0
AMenuItem.Caption = "Activate MyMenu"
AMenuItem.AddOnName = "ThisDocument.ConnectMyMenu"
'ConnectMyMenu it's my macro
AMenuItem.ActionText = "Run MyMenu"
AMenuItem.Enabled = True
Application.SetCustomMenus AUIObject
ActiveDocument.SetCustomMenus AUIObject
I create a VBA menu, inside a VSS file.
In my document, the menu is all the time in gray, impossible to
activate. Following my code, thanks to help me.
Dim AUIObject As Visio.UIObject
Dim AMenuSet As Visio.MenuSet
Dim AMenuItems As Visio.MenuItems
Dim AMenuItem As Visio.MenuItem
Dim AMenu As Visio.Menu
'Get the UI object for the copy of the MSOffice Menus
Set AUIObject = Visio.Documents.Application.BuiltInMenus
'(visMenuMSOffice)
'Get the Drawing Window Menusets
'NOTE: Use ItemAtID to get the Menuset.
'Using uiObj.MenuSets(visUIObjSetDrawing) will not work.
Set AMenuSet = AUIObject.MenuSets.ItemAtID(visUIObjSetDrawing)
Set AMenu = AMenuSet.Menus.Add
AMenu.Caption = "MyMenu"
'Get the MenuItems collection
Set AMenuItems = AMenu.MenuItems
'Add a new button in the first position
Set AMenuItem = AMenuItems.AddAt(0)
'Set the properties for the new Menu button
AMenuItem.CmdNum = 0
AMenuItem.Caption = "Activate MyMenu"
AMenuItem.AddOnName = "ThisDocument.ConnectMyMenu"
'ConnectMyMenu it's my macro
AMenuItem.ActionText = "Run MyMenu"
AMenuItem.Enabled = True
Application.SetCustomMenus AUIObject
ActiveDocument.SetCustomMenus AUIObject