0

I am working on visio add-ins using c#,VS 2012 and visio 2007.I am able to create Menu and Menu Item progmatically but when clicking on Menu item i.e. ChangeColor menu event is not firing.Any help will be appreciated.

Menu/Menu Item code :

            Visio.Application visioApplication;
            object visioObject = Marshal.GetActiveObject("Visio.Application");
            //converting object type to Visio type
            visioApplication = visioObject as Visio.Application;

            applicationCommandBars =
             (CommandBars)visioApplication.CommandBars;
            menuBar = applicationCommandBars.ActiveMenuBar;

            // Add a pop-up menu to the end of the active menu bar.
            menuPopup =
            (CommandBarPopup)menuBar.Controls.Add(MsoControlType.msoControlPopup, 1, "", 10, true);
            menuPopup.Caption = "&MyMenu"; ;

            menuItem = (CommandBarButton)menuPopup.Controls.Add(MsoControlType.msoControlButton, 1, "", 1, true);
            menuItem.Caption = "&ChangeColor"; ;
            menuItem.Style = MsoButtonStyle.msoButtonCaption;
            menuItem.Visible = true;
            menuItem.Click += menuItem_Click; 
user421719
  • 237
  • 2
  • 7
  • 20
  • Its possibly because you add the control before you define its event but I'm not convinced myself... what *is* happening? have you stepped through your code? – Sayse Sep 13 '13 at 09:32
  • Custom menu does not get fired once we load visio drawing file.If I changed the code to create and load custom menu in AddIn_Startup event it working there but not after loading the file. – user421719 Sep 13 '13 at 11:25

0 Answers0