Visio 2007自定义菜单单击事件未触发

时间:2013-09-13 09:22:47

标签: c# visual-studio office-interop visio visual-studio-addins

我正在使用c#,VS 2012和visio 2007处理visio插件。我能够以编程方式创建菜单和菜单项,但是当点击菜单项时,即ChangeColor菜单事件未触发。任何帮助将不胜感激。

菜单/菜单项目代码:

            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; 

0 个答案:

没有答案