G
goldnhue
My custom menu option loads whenever a Visio document loads, but I can't get
..AddOnName to run a procedure "MySub" that is located in a Module on the
Stencil. Any suggestions?
MenuItem.AddOnName = "MyModule.MySubroutine" <-- THIS DOES NOT WORK.
If needed, the complete menu setup code is below ... all else seems to work
fine.
Sub setmenu(ShpObj As Visio.shape)
' shpObj isn't used, just there to keep it from showing on the Macro menu
On Error GoTo ErrorTrap
Dim uiObj As Visio.UIObject
Dim menuSetsObj As Visio.MenuSets
Dim menuSetObj As Visio.MenuSet
Dim menusObj As Visio.Menus
Dim menuObj As Visio.Menu
Dim menuItemsObj As Visio.MenuItems
Dim menuItemObj As Visio.MenuItem
Dim deleting As Boolean
' Get a UI object copy of the built in Visio menus
Set uiObj = Visio.Application.BuiltInMenus
Set menuSetsObj = uiObj.MenuSets
' Get drawing window MenuSet Object
Set menuSetObj = menuSetsObj.ItemAtID(visUIObjSetDrawing)
'Get the Menus collection and add the PQMS menu to it at position 7
Set menusObj = menuSetObj.Menus
Set menuObj = menusObj.AddAt(7)
menuObj.Caption = "&Deva"
' Get the Menu Items collection and add the Deva menu option
Set menuItemsObj = menuObj.MenuItems
Set menuItemObj = menuItemsObj.Add
menuItemObj.Caption = "&Deva Menu"
menuItemObj.AddOnName = "MyModule.MySub" '<-- THIS DOESN'T WORK.
' Set the new menus.
Visio.Application.SetCustomMenus uiObj
' Tell Visio to use the new UI when the document is active.
ThisDocument.SetCustomMenus uiObj
Exit Sub
ErrorTrap:
End Sub
..AddOnName to run a procedure "MySub" that is located in a Module on the
Stencil. Any suggestions?
MenuItem.AddOnName = "MyModule.MySubroutine" <-- THIS DOES NOT WORK.
If needed, the complete menu setup code is below ... all else seems to work
fine.
Sub setmenu(ShpObj As Visio.shape)
' shpObj isn't used, just there to keep it from showing on the Macro menu
On Error GoTo ErrorTrap
Dim uiObj As Visio.UIObject
Dim menuSetsObj As Visio.MenuSets
Dim menuSetObj As Visio.MenuSet
Dim menusObj As Visio.Menus
Dim menuObj As Visio.Menu
Dim menuItemsObj As Visio.MenuItems
Dim menuItemObj As Visio.MenuItem
Dim deleting As Boolean
' Get a UI object copy of the built in Visio menus
Set uiObj = Visio.Application.BuiltInMenus
Set menuSetsObj = uiObj.MenuSets
' Get drawing window MenuSet Object
Set menuSetObj = menuSetsObj.ItemAtID(visUIObjSetDrawing)
'Get the Menus collection and add the PQMS menu to it at position 7
Set menusObj = menuSetObj.Menus
Set menuObj = menusObj.AddAt(7)
menuObj.Caption = "&Deva"
' Get the Menu Items collection and add the Deva menu option
Set menuItemsObj = menuObj.MenuItems
Set menuItemObj = menuItemsObj.Add
menuItemObj.Caption = "&Deva Menu"
menuItemObj.AddOnName = "MyModule.MySub" '<-- THIS DOESN'T WORK.
' Set the new menus.
Visio.Application.SetCustomMenus uiObj
' Tell Visio to use the new UI when the document is active.
ThisDocument.SetCustomMenus uiObj
Exit Sub
ErrorTrap:
End Sub