Creating and deletring Custom Menus in Visio

xiaoxiao2021-03-06  87

Introduction

There are several ways to handle the menus in Microsoft Visio application but are no events generated when the user click the menu.The best way to handle the menus and menu event handling is through CommandBars.Most of the sites i gone never find a solution. Some of the forums mentioned the idea how to import.i neweded Something Quicker to Find The Solution THEN I GOT THROUGH COMMANDBARS.HOPE THIS article Will Help You in All Aspects in Handling The Menu Bar.

WITH THIS ARTICLE NOT ONLY TO HANDLE THE MENUS in Microsoft.Visio We can Handle The Menus in All Microsoft Applications EX: Microsoft Word, Microsoft Excel, Microsoft Outlook, ETC.

This articles.

This Demo Needs 2 Components To Be Added Those Area Microsoft Office 11.0 Object Library, Microsoft Visio 11.0 Type Library.

This Demo Contains CustomMenu Class Which Will Take Care of Setting The Custom Menus and Deleting The Custom Menu from Standard Menu Bar of The Visio Application.

Let us start with the using decaration.

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 Commandbars of Microsoft Visio Application.

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 following Statement Will Work

Visio.uiObject uiobject = this.visioApplication.builtinmenus; after adding the menu to the menu bar of the visit to standard menu bar of the visio application with the following statement.

This.visioApplication.ActiveWindow.Document.SetCustomMenus (UIObject); To Get The Standard Commandbars of The Visio Application Following Statement Will Execute.

Commandbars = (Microsoft.Office.core.commandbars)

THISIAPPLICATION.COMMANDBARS;

Note:

* This Demo Requires Visio Application Should Run and It Requires a Default Drawing Should Be Opened.

Conclusion: CommandBars can be used for a lot of things, creating Menu Bars, ToolBars, etc.I feel CommandBar is the best way to handle the Micosoft Applications in your code and you can play with the applications.I hope you can make good use .

Download Source

转载请注明原文地址:https://www.9cbs.com/read-122429.html

New Post(0)