2

How can I call an excel macro with parameters from ABAP? I've found plenty of references for calling a macro without parameters online using the following method:

CALL METHOD OF obj_ex_APP 'Run' 
   EXPORTING #1 = 'Macro_ID'. 

But I can't find anywhere how to pass the parameter. Thanks for any pointers.

1 Answer 1

4

The arguments/parameters passed to the Macro are specified in consecutive parameters from ABAP.

So let's say you have a trivial macro like the following:

Sub Macro1(value)
    Range("A1").Select
    ActiveCell.FormulaR1C1 = value
End Sub

Then the corresponding code to call the Macro from ABAP will be

call method of excel 'Run'
  exporting #1 = 'Macro1'
            #2 = 'Wassup'. "<- Argument to the 'value' parameter

The only bump you might hit is that you can pass a maximum of 9 parameters to an OLE call from ABAP (correct me if I am wrong), while the Run method allows you to specify 30 parameters for a Macro, so you are left with 8 parameters you can pass to the macro.

For more info, see http://msdn.microsoft.com/en-us/library/office/ff197132.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.