PreviousNext
Help > Programming with LAUNCHER Office > LNCCMD commands > Commands list > XLEXEMACRO command
XLEXEMACRO command

Executes an EXCEL macro.

The macro can be present in the open workbook (.xls or .xlsm for example), or in an Excel add-in (.xla or .xlam), which can be loaded with the XLADDINS command.

 

Syntax

CHGVAR                VAR(&CMD)VALUE('XLEXEMACRO')

CHGVAR                VAR(&PARM1)VALUE('Macro name')

CHGVAR                VAR(&PARM2)VALUE('[Macro parameters]')

CALL                  PGM(LNCCMD) PARM(&HANDLE &CMD &OPT +

                      &PARM1 &PARM2 &RESULT)

 

Parameters

Parameters

 

Parm1

Macro name.

 

Parm2

Parameters of the macro.
Parameters must be within doubles quotes, separated with semicolon.

 

 

Example

 

CHGVAR                VAR(&CMD)VALUE('XLEXEMACRO')

CHGVAR                VAR(&PARM1)VALUE('Macro1')

CHGVAR                VAR(&PARM2) VALUE('"12000";"FRANCE"')

CALL                  PGM(LNCCMD) PARM(&HANDLE &CMD &OPT +

                      &PARM1 &PARM2 &RESULT)

or

 

CHGVAR                VAR(&CMD)VALUE('XLEXEMACRO')

CHGVAR                VAR(&PARM1)VALUE('Macro')

CHGVAR                VAR(&PARM2) VALUE(' ')

CALL                  PGM(LNCCMD) PARM(&HANDLE &CMD &OPT +

                      &PARM1 &PARM2 &RESULT)

 

In this example, macro is contained in the active workbook.

 

Other example

Suppose we have the following macro, with two parameters:

Sub ProcMsgBox(sParam1 As String, sParam2 As String)

MsgBox sParam1 & " - " & sParam2

End Sub

 

If the macro is in the active workbook, then this code will be used to run the macro:

LNCCMD CMD(EXCELOPEN)

LNCCMD CMD(XLOPENFILE) PARM1('C:\A\temp.xlsm')

LNCCMD CMD(XLEXEMACRO) PARM1('ProcMsgBox') + PARM2('"Aura";"Equipements"')

 

If the macro is in an XLAM add-in (or an XLA add-in), then we will use the following code to parse the add-in and then run the macro:

 

LNCCMD CMD(EXCELOPEN)

LNCCMD CMD(XLOPENFILE) PARM1('C:\A\temp.xlsx')

LNCCMD CMD(XLADDINS) PARM1('C:\A\ModelMacro.xlam')

LNCCMD CMD(XLEXEMACRO) PARM1('ProcMsgBox') + PARM2('"Aura";"Equipements"')

 

See also

         XLMETHOD

         XLADDINS