Is it possible to change the default right click menu for all shapes
in the current document, via the type library? If so what object(s)
do I need to modify using the type library?
Thanks,
Ted
The command bar named "Shortcut menus" has a series of submenus; the submenu
named "Drawing Object Selected" equates to the right-click menu for selected
shapes. If you want to modify this menu for the current document, you can
use the UIObject.MenuSets' named constants for the various menus to get the
right one:
Public Sub ModifyShapeRightClickMenu()
Dim uio As Visio.UIObject
Set uio = Application.BuiltInMenus
Dim mnu As Visio.Menu
Set mnu = uio.MenuSets.ItemAtID(visUIObjSetCntx_DrawObjSel) _
.Menus.Item(0)
Dim newItem As Visio.MenuItem
Set newItem = mnu.MenuItems.Add
newItem.Caption = "Hi there"
newItem.AddOnName = "ThisDocument.SayHi"
ThisDocument.SetCustomMenus uio
End Sub
If you prefer to use the MSO CommandBar object model, you can access this
menu by name:
Public Sub AddMsoCommandBarToShapeRightClickMenu
Dim cb As Office.CommandBarPopup
Set cb = Application.CommandBars("Shortcut menus").Controls(1)
Dim cbc As Office.CommandBarControl
Set cbc = cb.Controls.Add(temporary:=True)
cbc.Caption = "Say Hi"
cbc.OnAction = "ThisDocument.SayHi"
End Sub
Michael J. Hunter
Microsoft Visio
michhu-at-online-dot-microsoft-dot-com
Developing Microsoft Visio Solutions:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devref/DVS_
Copyright_1270.asp?frame=true
Developer Resources for Microsoft Visio:
http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid
=28000456
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
>.
>