Programming with Reflection

image\rwnprg32.gif RunMacro method


Syntax object.RunMacro MacroName, MacroData



Runs a macro. You can use the second argument to pass information to the macro.

For example, the following statement runs the FirstLogin macro and sets MacroData to "Joe":

Session.FirstLogin "AskUser", "Joe"


MacroName Argument type: String
Specifies the name of the macro to run.

 An error occurs if there is no macro of this name in the current settings file or in any referenced files. This value can be up to 255 characters long.

 If macros of the same name are in your settings and a referenced file, use both the project name and the macro name to identify the macro. Place a period between the project and macro name. For example, "SharedMacros.Login" identifies the "Login" macro in the "SharedMacros" settings file.

MacroData Argument type: String
Sets the value of the MacroData property. This value can be up to 260 characters long.

Note: Because each macro is a public procedure within your project, you can also run macros by calling the macro procedure. The procedure name is the same as the macro name. For example, each of the following statements will run a macro named DoStuff. (Look up "Call statement" in the Visual Basic Editor's Help for information about calling procedures.)

Call DoStuff


Session.RunMacro "DoStuff", ""

Use RunMacro when you want to map a macro to a Reflection feature, such as a toolbar button or keystroke, to pass information to MacroData, or when you want to use a string expression to identify the name of the macro. String expressions can be created at run time as follows:

Session.RunMacro "macro" & Str$(1), ""


image\jump.gif Example

image\jump.gif Keyword Index

image\popup.gif Related Topics

image\popup.gif Reflection products that use this command