RUNADDON function

Microsoft Office ShapeSheet

RUNADDON function

See also

Executes an add-on or passes code to be executed to the Microsoft Visual Basic for Applications (VBA) project of the document containing the operand.

Syntax

RUNADDON("string")

string

The name of an add-on or a line of code that VBA recognizes, such as the name of a macro, a procedure with arguments, or a command that the VBA Immediate window can execute.

Remarks

If the project cannot execute string, Microsoft Visio runs the add-on named string. If no add-on named string can be found, Visio does nothing and reports no error.

In earlier versions of Visio, this function appears as _RUNADDON. Visio versions 4.0 and later accept either style.

Beginning with Microsoft Visio 2002, evaluation of RUNADDON does not create a new project. In earlier versions, a VBA project was created in the operand's document if no project existed already. For example, in Visio 2002, the evaluation of =RUNADDON("msgbox ""hello""") shows the message box if the document contains a project; otherwise, it does nothing. You can create a document project by opening the Visual Basic Editor when the document is open.

Note VBA code invoked as a result of a Visio instance evaluating a RUNADDON operand in a formula should not use the Document.Close method to close the document containing the function's cell because an application error results and Visio terminates.

If you need to close the document containing the cell that uses the RUNADDON function, use one of the following techniques:

  • Close the document from non-VBA code.
  • Close the document from a project other than the one that is closing.
  • Post window messages to close windows into the document rather than closing the document.

Example 1

RUNADDON("Calendar.exe")

Launches the Calendar.exe add-on.

Example 2

RUNADDON("summation 1, 2, 3")

Calls the VBA procedure named summation and passes three arguments.

Example 3

RUNADDON("debug.print ""xyz""")

Prints "xyz" in the VBA Immediate window.

Example 4

RUNADDON("ThisDocument.Save")

Saves the document containing the function.