Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer

up vote 2 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.