Custom menu calls a sub from another document

Started by chrisoft, April 04, 2016, 10:02:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chrisoft

Dear Visio developers,

I have a project document which handles every opened documents.
I need to add a custom menu (from a sub of the project) into the opened docs. the thing is that the menu added is not calling the function I need.
The caption is still in grey if I use AddonName method whereas if I use AddonArgs method, the menu is not grey anymore but not calling the function


Here is the code :

Sub Menuadd()


    Dim AUIObject        As UIObject
    Dim AMenuSet         As MenuSet
    Dim AMenuItems       As MenuItems
    Dim AMenuItem        As MenuItem
    Dim Amenu            As Menu

    'Get the UI object for the copy of the MSOffice Menus
    Set AUIObject = Visio.Documents.Application.BuiltInMenus '
   
    'Get the Drawing Window Menusets
   
    Set AMenuSet = AUIObject.MenuSets.ItemAtID(visUIObjSetDrawing)
    Set Amenu = AMenuSet.Menus.AddAt(0)  '.Add
    Amenu.Caption = "Test"
   
    'Get the MenuItems collection
    Set AMenuItems = Amenu.MenuItems
   
    'Add a new button in the first position
    Set AMenuItem = AMenuItems.AddAt(0)


    AddMenu_Option AMenuItems.AddAt(0), 0, "myCaption", "project_name.module.sub_Into_module", "myAction Name", True
   
    Application.SetCustomMenus AUIObject
    ActiveDocument.SetCustomMenus AUIObject
End Sub


Sub AddMenu_Option(pMenu As Visio.MenuItem, pNum As Integer, pCaption As String, pAddon As String, pAction As String, pEnabled As Boolean)
    pMenu.CmdNum = pNum
    pMenu.Caption = pCaption
    pMenu.AddOnArgs= pAddon
    pMenu.ActionText = pAction
    pMenu.Enabled = pEnabled

End Sub

In case of you have an idea, please let me know