|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThere are several ways to handle the menus in the Microsoft Visio application, but there are no events generated when the user clicks the menu. The best way to handle the menus and menu event handling is through With this article, you can not only to handle the menus in Microsoft Visio, but also the menus in some other Microsoft applications. E.g.: Microsoft Word, Microsoft Excel, Microsoft Outlook, etc. This article concentrates more on Microsoft Visio. In this article, I will show you how to create custom menus and how to handle menu click event handlers. This demo needs 2 components to be added: those are Microsoft Office 11.0 Object Library, Microsoft Visio 11.0 Type Library. Code:This demo contains Let us start with the using Visio=Microsoft.Office.Interop.Visio;
The above statement includes Microsoft Visio interop services. Secondly, private variables declaration: private Microsoft.Office.Core.CommandBars commandBars;
private Microsoft.Office.Core.CommandBar commandBar;
private Microsoft.Office.Core.CommandBarButton commandBarButton;
The above variables are use to hold the standard private Visio.Application visioApplication;
object visioObject = Marshal.GetActiveObject("Visio.Application");
this.visioApplication = visioObject as Visio.Application;
The above statements holds the visio application reference.
To get the built in menus from the Visio application, the following statement will work: Visio.UIObject uiObject = this.visioApplication.BuiltInMenus;
After adding the menu to the menu bar, it should be set to standard menu bar of the Visio application with the following statement: this.visioApplication.ActiveWindow.Document.SetCustomMenus(uiObject);
To get the standard commandBars=
(Microsoft.Office.Core.CommandBars) this.visioApplication.CommandBars;
Note:*This demo requires that Visio application should be run, and it requires a default drawing to be open. Conclusion:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||