The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Run Method

Office 2003

Runs a Visual Basic macro.

expression .Run(MacroName, varg1, varg2, varg3, varg4, varg5, varg6, varg7, varg8, varg9, varg10, varg11, varg12, varg13, varg14, varg15, varg16, varg17, varg18, varg19, varg20, varg21, varg22, varg23, varg24, varg25, varg26, varg27, varg28, varg29, varg30)

expression Required. An expression that returns an Application object.

MacroName     Required String. The name of the macro. Can be any combination of template, module, and macro name. For example, the following statements are all valid.

    Application.Run "Normal.Module1.MAIN"
Application.Run "MyProject.MyModule.MyProcedure"
Application.Run "'My Document.doc'!ThisModule.ThisProcedure"

If you specify the document name, your code can only run macros in documents related to the current context — not just any macro in any document.

varg1...varg30     Optional Variant. Macro parameter values. You can pass up to 30 parameter values to the specified macro.


Although Visual Basic code can call a macro directly (without using the Run method), this method is useful when the macro name is stored in a variable. (For more information, see the example for this topic). The following three statements are functionally equivalent. The first two statements require a reference to, the project in which the called macro resides; the third statement, which uses the Run method, does not require a reference to the project.

Call Normal.Module2.Macro1
Application.Run MacroName:="Normal.Module2.Macro1"


This example prompts the user to enter a template name, module name, macro name, and parameter value, and then it runs that macro.

    Dim strTemplate As String
Dim strModule As String
Dim strMacro As String
Dim strParameter As String

strTemplate = InputBox("Enter the template name")
strModule = InputBox("Enter the module name")
strMacro = InputBox("Enter the macro name")
strParameter = InputBox("Enter a parameter value")
Application.Run MacroName:=strTemplate & "." _
    & strModule & "." & strMacro, _

Applies to | Application Object