visio 2003 menu

R

Rad

Hi,

I have replaced this string "RS_Visio_Script.NewMacros.RerunPSIT" with
"MyMacro"
at vsoMenuItem.AddOnName = "MyMacro" (See below), which made the macro not
work.

Does any one know what I need to do to make an outside macro, located in a
Stencil, work? The code below works and calls MyMacro macro if it’s in the
Active document, but does not work if the macro in a Stencil.

Thanks,
Rad



Public Sub AddAt_Example()
Dim vsoUI As Visio.UIObject
Dim vsoMenuSets As Visio.MenuSets
Dim vsoMenuSet As Visio.MenuSet
Dim vsoMenus As Visio.Menus
Dim vsoMenu As Visio.Menu
Dim vsoMenuItems As Visio.MenuItems
Dim vsoMenuItem As Visio.MenuItem

'Get a UI object that represents Microsoft Office Visio built-in menus.
Set vsoUI = Visio.Application.BuiltInMenus

'Get the MenuSets collection.
Set vsoMenuSets = vsoUI.MenuSets

'Get the drawing window menu set.
Set vsoMenuSet = vsoMenuSets.ItemAtID(visUIObjSetDrawing)

'Get the Menus collection.
Set vsoMenus = vsoMenuSet.Menus

'Add a Demo menu before the Window menu.
Set vsoMenu = vsoMenus.AddAt(7)
vsoMenu.Caption = "Demo"

'Get the MenuItems collection.
Set vsoMenuItems = vsoMenu.MenuItems

'Add a menu item to the new Demo menu.
Set vsoMenuItem = vsoMenuItems.Add

'Set the properties for the new menu item.
vsoMenuItem.Caption = "Run & MyMacro"
vsoMenuItem.AddOnName = "MyMacro"
vsoMenuItem.ActionText = "Run MyMacro"

'Tell Visio to use the new UI when the document is active.
ThisDocument.SetCustomMenus vsoUI

End Sub
 
J

JuneTheSecond

I've not tested it, but please try next,
vsoMenuItem.AddOnName = "ProjectName!Module1.MyMacro"

To run macro on another project, project name + ! + module name + . +macro
name might do. ProjectName might be found in the project explorer in VBA
editor.
 
J

JuneTheSecond

Then, try vsoMenuItem.AddOnName = "ProjectName.Module1.MyMacro"
This is project name + "." + module name + "." + macro name. not "!".
And turn-on the check box of reference to the stencil's project at menu
tools, reference in VBA editor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top