M
Mikk
I'm currently working on a VB.NET 2003 COM Add-in Project for Visio 2003.
I'm trying to add two new menu items to the View Menu. I've tried using the
Microsoft.Office.Interop.Visio namespace and the Microsoft.Office.Core
namespace and moth methods failed.
Using the Microsoft.Office.Interop.Visio method I was able to add two new
Menu Items using the Visio.UIObject and Document.SetCustomMenus(). The method
worked and I created a custom UI that would add two menu items uder the View
Menu. The problem is I can't customize the picture displayed on the left side
of Menu as an Icon before the Menu Item Caption.
Following is the code I've used:
===============[ Code Begin ] ==========================
Dim AUIObject As Microsoft.Office.Interop.Visio.UIObject
Dim AMenuSet As Microsoft.Office.Interop.Visio.MenuSet
Dim AMenu As Microsoft.Office.Interop.Visio.Menu
Dim AMenuItem As Microsoft.Office.Interop.Visio.MenuItem
AUIObject = myVisioApp.BuiltInMenus
AMenuItem = AUIObject.MenuSets(0).Menus(2).MenuItems.AddAt(6)
AMenuItem.Caption = "Action Tables Window"
AMenuItem.Enabled = True
AMenuItem.Visible = True
AMenuItem.Style = visio.VisUIButtonStyle.visButtonIconandCaption
AMenuItem.FaceID = -1
AMenuItem.IconFileName("c:\work\myPrj\images\test.ico")
doc.SetCustomMenus(AUIObject)
AUIObject.UpdateUI()
===============[ Code End ] ============================
** Note:
doc is a Visio.Document and myVisioApp is a reference to the visio
application that my addin connects to. The code above sits inside the
DocumentCreated handler.
The result is a new menu item under the View Menu that has a black box
instead of an image.
** Note:
I've also tried to use the Microsoft.Office.Core.CommandBar and
Microsoft.Office.Core.CommandBarButton classes to get a reference to the menu
items i have just created and to use them to set a menu item icon. That did
not work either. Code is provided as follows:
===============[ Code Begin ] ============================
cbrs = CType(myVisioApp.CommandBars,
_Microsoft.Office.Core.CommandBars)
cb = cbrs("Menu Bar")
cb.Protection = office.MsoBarProtection.msoBarNoMove
myCBBActionTables = CType(cb.Controls("View"),
_office.CommandBarPopup).Controls("Action Tables
Window")
myCBBActionTables.Picture = aPic
myCBBActionTables.Mask = aPic
===============[ Code End ] ============================
**Note:
The code references the Menu Item succesfully as I can verify properties
such as the caption and assign handlers for the click event but assiging the
Pciture and Mask don't work either. The aPic is an object of type:
stdole.IPictureDisp.
I'm trying to add two new menu items to the View Menu. I've tried using the
Microsoft.Office.Interop.Visio namespace and the Microsoft.Office.Core
namespace and moth methods failed.
Using the Microsoft.Office.Interop.Visio method I was able to add two new
Menu Items using the Visio.UIObject and Document.SetCustomMenus(). The method
worked and I created a custom UI that would add two menu items uder the View
Menu. The problem is I can't customize the picture displayed on the left side
of Menu as an Icon before the Menu Item Caption.
Following is the code I've used:
===============[ Code Begin ] ==========================
Dim AUIObject As Microsoft.Office.Interop.Visio.UIObject
Dim AMenuSet As Microsoft.Office.Interop.Visio.MenuSet
Dim AMenu As Microsoft.Office.Interop.Visio.Menu
Dim AMenuItem As Microsoft.Office.Interop.Visio.MenuItem
AUIObject = myVisioApp.BuiltInMenus
AMenuItem = AUIObject.MenuSets(0).Menus(2).MenuItems.AddAt(6)
AMenuItem.Caption = "Action Tables Window"
AMenuItem.Enabled = True
AMenuItem.Visible = True
AMenuItem.Style = visio.VisUIButtonStyle.visButtonIconandCaption
AMenuItem.FaceID = -1
AMenuItem.IconFileName("c:\work\myPrj\images\test.ico")
doc.SetCustomMenus(AUIObject)
AUIObject.UpdateUI()
===============[ Code End ] ============================
** Note:
doc is a Visio.Document and myVisioApp is a reference to the visio
application that my addin connects to. The code above sits inside the
DocumentCreated handler.
The result is a new menu item under the View Menu that has a black box
instead of an image.
** Note:
I've also tried to use the Microsoft.Office.Core.CommandBar and
Microsoft.Office.Core.CommandBarButton classes to get a reference to the menu
items i have just created and to use them to set a menu item icon. That did
not work either. Code is provided as follows:
===============[ Code Begin ] ============================
cbrs = CType(myVisioApp.CommandBars,
_Microsoft.Office.Core.CommandBars)
cb = cbrs("Menu Bar")
cb.Protection = office.MsoBarProtection.msoBarNoMove
myCBBActionTables = CType(cb.Controls("View"),
_office.CommandBarPopup).Controls("Action Tables
Window")
myCBBActionTables.Picture = aPic
myCBBActionTables.Mask = aPic
===============[ Code End ] ============================
**Note:
The code references the Menu Item succesfully as I can verify properties
such as the caption and assign handlers for the click event but assiging the
Pciture and Mask don't work either. The aPic is an object of type:
stdole.IPictureDisp.