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

Executing Excel Macros from SAP

Former Member
0 Likes
613

Hi all Experts,

I have created a program which tranfers data from different internal tables into Different Worksheets of a single workbook.

Now, Can some one please tell me how to Execute macros from SAP.

Regards,

AJ

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
545

To execute an Excel macro follow these steps.

1. Create macro inside Excel Workbook where you transferred your information.

2. Use following instruction to execute the desired macro you create:

DATA: EXCEL TYPE OLE2_OBJECT.

CREATE OBJECT EXCEL 'Excel.Application'.

...

CALL METHOD OF EXCEL 'Run' EXPORTING #1 = 'WRITE_SHEET_CELL'

#2 = 'VALUE1'

#3 = 'VALUE2'

#4 = 'VALUE3'.

In previous example, macro WRITE_SHEET_CELL was created first. The macro name must be in uppercase.

Regards.

Rafael Rojas.

1 REPLY 1
Read only

Former Member
0 Likes
546

To execute an Excel macro follow these steps.

1. Create macro inside Excel Workbook where you transferred your information.

2. Use following instruction to execute the desired macro you create:

DATA: EXCEL TYPE OLE2_OBJECT.

CREATE OBJECT EXCEL 'Excel.Application'.

...

CALL METHOD OF EXCEL 'Run' EXPORTING #1 = 'WRITE_SHEET_CELL'

#2 = 'VALUE1'

#3 = 'VALUE2'

#4 = 'VALUE3'.

In previous example, macro WRITE_SHEET_CELL was created first. The macro name must be in uppercase.

Regards.

Rafael Rojas.