R
Rad
I am trying to create a menu item, and the code is in a Stencil. I then load
the Stencil by running a script, which lunch Visio 2003, and creates
“Drawing1â€.
The code below works on a drawing page when it is in the document, but when
I put the code in the Stencil, the code does not work, because it is not
pointing to the ThisDocument (Drawing1). I need to make the code in the
Stencil point to the open and activated document so it can work.
Any solutions, or ideas?
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
Thanks,
Rad
the Stencil by running a script, which lunch Visio 2003, and creates
“Drawing1â€.
The code below works on a drawing page when it is in the document, but when
I put the code in the Stencil, the code does not work, because it is not
pointing to the ThisDocument (Drawing1). I need to make the code in the
Stencil point to the open and activated document so it can work.
Any solutions, or ideas?
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
Thanks,
Rad