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

Run macro in ABAP Code

Former Member
0 Likes
1,226

Dear all,

I am using OLE in ABAP Code to download excel file through my ABAP Code as below:

CREATE OBJECT W_EXCEL 'EXCEL.APPLICATION'. "CREATE OBJECT FOR EXCEL

   SET PROPERTY OF W_EXCEL  'VISIBLE' = 1. "IN BACKGROUND MODE

   CALL METHOD OF W_EXCEL 'WORKBOOKS' = W_WORKBOOK.

   CALL METHOD OF W_WORKBOOK 'ADD'. "CREATE A NEW WORKBOOK

   SET PROPERTY OF W_EXCEL 'SHEETSINNEWWORKBOOK' = 1. "NO OF SHEETS

   SET PROPERTY OF W_EXCEL 'DisplayAlerts' = 0.

   CALL METHOD OF W_EXCEL 'WORKSHEETS' = sheet

   EXPORTING

     #1 = 1.

   CALL METHOD OF w_excel 'ActiveWorkbook' = W_WORKSHEET.


and so on..


I want the below macro code to run while downloading,

Private Sub Workbook_Open()

Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"

End Sub

Please guide how to incorporate/convert the same in OLE ABAP Code.

Thanks

Chehak

2 REPLIES 2
Read only

RicardoRomero_1
Active Contributor
0 Likes
716

Hi,


Have you tried with this?


CALL METHOD OF W_EXCEL 'ExecuteExcel4Macro'

      EXPORTING #1 = '"SHOW.TOOLBAR(""Ribbon"",False)"'.


or this?

CALL METHOD OF W_EXCEL 'SendKeys'

   EXPORTING #1 = '^{F1}'.

Regards,
Ricardo.

Read only

0 Likes
716

CALL METHOD OF W_EXCEL 'ExecuteExcel4Macro'

      EXPORTING #1 = '"SHOW.TOOLBAR(""Ribbon"",False)"'.


The above code works to disable the button across the menubars but the 'Office Button' is still open for usage. When i apply the macro in excel. I get the below view of excel.

But while using the code specified in ABAP, the following output in excel is achieved. I need to get the above functionality. Hope you can help.