Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Modify right click menu for shapes..

0 views
Skip to first unread message

Ted

unread,
Dec 17, 2002, 9:54:57 AM12/17/02
to
Hello,
I'm working on an application that requires changes to the right
click menu for every shape in my document. I know how to change the
menu on individual shapes, via an action cell in the Visio 2002 Type
Library. However, I would prefer not to have to execute this code
segment for every shape in my document
(I have the potential to have 100s of shapes).

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

Michael J. Hunter

unread,
Dec 17, 2002, 11:58:01 AM12/17/02
to
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


Ted

unread,
Dec 17, 2002, 1:27:01 PM12/17/02
to
Thanks Michael!
-Ted

>.
>

0 new messages