Programming with Reflection
RunMacro method
Syntax object.RunMacro MacroName, [MacroData]
Runs a macro.
For example, the following statement runs the FirstLogin macro and sets MacroData to "Joe."
Session.FirstLogin "AskUser", "Joe"
MacroName Argument type: String
Required
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 both 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
Optional
Specifies information to be passed to the MacroData property. This value can be up to 255 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 online help for information about calling procedures.)
Call DoStuff
DoStuff
Use RunMacro when you want 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 shown here:
Session.RunMacro "macro" & Str$(1)