Caption Property [Visio 2003 SDK Documentation]
Gets or sets the caption for an object.
object**.Caption** = stringVal
stringVal = object**.Caption**
object Required. An expression that returns an object in the Applies to list that has or gets the caption.
stringVal Required String. The caption of the object.
Version added
4.0
Remarks
Visio does not use the Caption property of a MenuSet or ToolbarSet object.
- Use an ampersand (&) in the string to cause the next character in the string to become the shortcut key for that menu or menu item. For example, the string "F*&o*rmat" causes o to become the shortcut key for that menu item in that one menu.
- Use "" in the string to display a double quotation mark on the menu.
- Use && in the string to display an ampersand on the menu.
Example
The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the Caption property. It adds a menu and menu item to the drawing window menu set and sets the menu and menu item's Caption properties.
To restore the built-in menus in Microsoft Office Visio after you run this macro, call the ThisDocument.ClearCustomMenus method.
Public Sub Caption_Example()
Dim vsoUIObject 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 UIObject object that represents Microsoft Visio built-in menus.
Set vsoUIObject = Visio.Application.BuiltInMenus
'Get the MenuSets collection.
Set vsoMenuSets = vsoUIObject.MenuSets
'Get the drawing window menu set.
Set vsoMenuSet = vsoMenuSets.ItemAtID(visUIObjSetDrawing)
'Get the Menus collection.
Set vsoMenus = vsoMenuSet.Menus
'Add a new menu before the Window menu.
Set vsoMenu = vsoMenus.AddAt(7)
vsoMenu.Caption = "MyNewMenu"
'Get the MenuItems collection.
Set vsoMenuItems = vsoMenu.MenuItems
'Add a menu item to the new menu.
Set vsoMenuItem = vsoMenuItems.Add
'Set the Caption property for the new menu item.
vsoMenuItem.Caption = "&MyNewMenuItem"
'Tell Visio to use the new UI when the document is active.
ThisDocument.SetCustomMenus vsoUIObject
End Sub
Applies to | Menu object | MenuItem object | MenuSet object | Toolbar object | ToolbarItem object | ToolbarSet object | Window object
See Also | AccelItem object | ActionText property | CmdNum property