Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Attachmate.Reflection.Objects.Emulation.OpenSystems Library / Macro Object / RunMacro3 Method
A ProjectOption value. The location of the macro. ProjectOption_CurrentProject refers to a macro in the current session document's VBA project. ProjectOption_CommonProject refers to a macro in the Common VBA project.
The name of the macro to run.
An array of parameters to pass to the macro.
Example
In This Topic
    RunMacro3 Method (Macro)
    In This Topic
    Runs a macro that takes an array of parameters.
    Syntax
    expression.RunMacro3( _
       ByVal macroSource As ProjectOption, _
       ByVal macroName As String, _
       ByRef macroParameters() As Object _
    ) 
    where expression is a variable that represents a Macro Object

    Parameters

    macroSource
    A ProjectOption value. The location of the macro. ProjectOption_CurrentProject refers to a macro in the current session document's VBA project. ProjectOption_CommonProject refers to a macro in the Common VBA project.
    macroName
    The name of the macro to run.
    macroParameters
    An array of parameters to pass to the macro.
    Example
    The following example demonstrates calling macros that take various parameters. The example also demonstrates a scenario of passing in an invalid parameter type.
    ' Following example provides details on how to use RunMacro3 method
    Sub RunMacro3Example()
        Dim params() As Variant
        
        params = Array(123, "param 2 data")
        ThisTerminal.macro.RunMacro3 ProjectOption_CurrentProject, "Module1.MacroWithTwoParam", params
           
        params = Array("param 1 data", 222, "param 3 data")
        ThisTerminal.macro.RunMacro3 ProjectOption_CurrentProject, "Module1.MacroWithThreeParam", params
     
        ' Example of calling macro with invalid parameter type. Invalid type passed in to parameter 2
        params = Array("param 1 data", "param 2 data", "param 3 data")
        ThisTerminal.macro.RunMacro3 ProjectOption_CurrentProject, "Module1.MacroWithThreeParam", params
        
    End Sub
     
    Sub MacroWithTwoParam(param1 As Integer, param2 As String)
        MsgBox "MacroWithTwoParam called with two parameters: param1='" & param1 & "' param2 = '" & param2 & "'"
    End Sub
     
    Sub MacroWithThreeParam(param1 As String, param2 As Integer, param3 As String)
        MsgBox "MacroWithThreeParam called with three parameter: param1='" & param1 & "' param2 = '" & param2 & "' param3 = '" & param3 & "'"
    End Sub
    See Also