10-23-2015 9:02 AM
Hello experts,
I need to call an Excel Macro from ABAP, I am using i_oi_document_proxy->execute_macro, but when I execute I dont know how to 'accept' the parameters in my Macro, and to make it even harder for example when I declare parameters in my Macro as below:
Public Sub Macro3(v_start as String, v_end as String)
'
' Macro3 Macro
'
'
Range("A1:A29").Select
Selection.Rows.Group
End Sub
The Excel won't recognize my Macro and SAP won't call it
I hope I was clear,
Regards,
Dren
10-23-2015 4:42 PM
10-26-2015 9:31 AM
Hi.
Probably you're calling your Sub in an incorrect way. You must refear always your MainModule in the "name sub parameter".
If you declare a Sub like this
You should not find any problems calling from SAP in this way
CALL METHOD gr_proxy->EXECUTE_MACRO
EXPORTING
MACRO_STRING = 'MainModule.HideSheet'
PARAM1 = loc_sheetname
PARAM_COUNT = 1
IMPORTING
ERROR = gr_error
RETCODE = gwf_retcode.
Hope to help
Bye
10-26-2015 3:17 PM
Hello Roberto,
This is the Macro I have:
Public Sub Macro1(v_start as String, v_end as String)
'
' Macro1 Macro
'
'
MsgBox v_start
MsgBox v_end
Range("B9:B11").Select
Selection.Rows.Group
Range("B9:B12").Select
Range("B12").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"
Range("B9:B12").Select
End Sub
This is how I call it from ABAP,
CALL METHOD gc_document->execute_macro
EXPORTING
macro_string = 'SAPMain.Macro1'
param1 = v_start
param2 = v_end.
As you can see I also used two MsgBox command to see if any data comes from ABAP but it shows nothing,
Can you tell by this what am I doing wrong
Regards,
Dren
10-26-2015 3:46 PM
Hi.
Probably you're missing " PARAM_COUNT = 2 "as parameter in the call method.
Try this.
Hope to help
Bye