Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Execute Excel macros from ABAP

Former Member
0 Likes
3,325

Hi,

I've used OLE to export data from SAP to Excel, so I have the document, and at last I'd like to execute a Excel macro from ABAP inside this new Excel that I've just created, is it possible? Where should I store the Excel macro?.

I've read about I_OI_DOCUMENT_PROXY interface, but I can't execute the macro yet.

Please, if somebody knows how to do it, it would be great.

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
1,421

Hi Mario,

CREATE OBJECT go_excel 'EXCEL.APPLICATION' .

SET PROPERTY OF go_excel 'Visible' = 1 .

GET PROPERTY OF go_excel 'Workbooks' = gs_wbooks .

GET PROPERTY OF go_wbooks 'Application' = go_app .

CALL METHOD OF go_app 'Run'

     EXPORTING #1 = macro_string .

Regards

Read only

0 Likes
1,421

Hi Mohammed,

I've tried, but I don't know where store the Excel macro to be executed from SAP (C:\Windows\System32??), and which name and extension. I'd need some real example.

Read only

0 Likes
1,421

Hi Mario,

The Macros you want to execute are and should be part of global excel template.

It is not in any system32 folder.....

To execute anything you need to connect to it... so

You need to create and EXCEL OLE Object.

Open the WorkBook and then Execute the Macro.

the macro_string is the name of the Macro you want to execute.

Regards

Read only

Former Member
0 Likes
1,421

Hi Mario,

I have never executed an Excel Macro.
But found this sample report SAPRDEMOEXCELINTEGRATION.
It calls MACRO 'R3StartupMacro' at line number 288.

In OAOR & SBDSV1 Transaction codes, you will need to give

CLASS NAME = SOFFICEINTEGRATION and CLASS TYPE = OT to see associated details.

Regards,
Nisha Vengal.

Read only

0 Likes
1,421

Hi Mario,

Check reply by Lars on thread http://scn.sap.com/thread/148656

  1. Appends Source Code Internal table
    Sub functionname()
    ...
    End Sub
  2. Then calls method passing source code internal table. Gets a script name OKADIS
    Call method pptr_script_collection->add_script_from_table
  3. Runs EXECUTE_MACRO using that script name OKADIS

Check original post by Rebecca on thread http://scn.sap.com/thread/26946


DATA: macro_string(50) TYPE c VALUE 'FB03process.FromTheBeginning'

Short MACRO as "EXCELNAME.FromTheBeginning" is directly written in EXECUTE_MACRO method.

Regards,

Nisha Vengal.