AddOnArgs Property
The document is archived and information here might be outdated

AddOnArgs Property [Visio 2003 SDK Documentation]

Office 2003

Gets or sets the argument string that you send to the add-on associated with a particular menu or toolbar.

object.AddOnArgs = argsStr

argsStr = object.AddOnArgs

object     Required. An expression that returns an object in the Applies to list that starts the add-on.

argsStr     Required String. The argument string to be passed to the add-on.

Version added



An argument's string can be anything appropriate for the add-on. However, the arguments are packaged together with other information into a command string, which cannot exceed 127 characters. For best results, limit arguments to 50 characters.

An object's AddOnName property indicates the name of the add-on to which the arguments are sent.

Beginning with Visio 2002, the AddOnName property used in the following example cannot execute a string that contains arbitrary Microsoft Visual Basic code. To call code that in previous versions of Visio you would have passed to the AddOnName property, move it to a procedure in a document's Visual Basic project that is called from the AddOnName property, as shown in the following example.


This Microsoft Visual Basic for Applications (VBA) macro shows how to set the AddOnArgs property of a menu item. It also shows how to add a menu and menu item to the drawing window menu set and how to set some of the menu item's other properties, such as Caption, AddOnName, and ActionText.

This example assumes that you already have a macro in the current Visual Basic project, and that that macro takes one argument called "Arg1". Before running this example, replace macroname with the name of your macro.

To restore the built-in menu set after running this macro, use the ThisDocument.ClearCustomMenus method.

Public Sub AddonArgs_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 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 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 &("macroname")" 
    vsoMenuItem.AddOnName = "ThisDocument.("macroname")" 
    vsoMenuItem.AddOnArgs = "/Arg1 = True" 
    vsoMenuItem.ActionText = "Run ("macroname")" 

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

End Sub

© 2016 Microsoft