Run Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

                 

Syntax 1: Runs a macro or calls a function. This can be used to run a macro written in Visual Basic or the Microsoft Excel 4.0 macro language, or to run a function in a DLL or XLL.

Syntax 2: Runs the Microsoft Excel 4.0 macro at this location. The range must be on a macro sheet.

Syntax 1

expression**.Run(Macro**, Arg1, Arg2, ...)

Syntax 2

expression**.Run(Arg1, Arg2, ...)**

expression   Optional for Application, required for Range. An expression that returns the application that contains the macro, or a range on a macro sheet that contains a Microsoft Excel 4.0 macro.

Macro   Required Variant for Syntax 1 (not used with Syntax 2). The macro to run. This can be either a string with the macro name, a Range object indicating where the function is, or a register ID for a registered DLL (XLL) function. If a string is used, the string will be evaluated in the context of the active sheet.

Arg1, Arg2, ...   Optional Variant. The arguments that should be passed to the function.

Remarks

You cannot use named arguments with this method. Arguments must be passed by position.

The Run method returns whatever the called macro returns. Objects passed as arguments to the macro are converted to values (by applying the Value property to the object). This means that you cannot pass objects to macros by using the Run method.