Application Development 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: 

How to add a new worksheet to already existing excel file on desktop via ole?

sh4il3sh
Participant
0 Kudos
533

I have an excel worksheet, which needs to be updated with a new worksheet to be added.
How can I achieve this using Ole2object?

I am able to open the excel sheet but unable to add a new worksheet to it.
I can use abap2xlsx but the process to get it moved to prod needs approval and would take time. so avoiding for now.

CREATE OBJECT gra_excel 'EXCEL.APPLICATION'.
CALL METHOD OF gra_excel 'Workbooks' = gra_workbooks.
SET PROPERTY OF gra_excel  'Visible' = 1.
CALL METHOD OF gra_workbooks 'OPEN'
  EXPORTING
    #1 = filep.

after this I am able to access other worksheets in the same excel but unable to add new worksheets.
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
447

In Excel, you have a macro recorder. Record the creation of a worksheet and in the recorded VBA, you will get the property and method to be used (and parameter).

3 REPLIES 3

Sandra_Rossi
Active Contributor
448

In Excel, you have a macro recorder. Record the creation of a worksheet and in the recorded VBA, you will get the property and method to be used (and parameter).

447

You are the best.

sh4il3sh
Participant
447

Thank you very much, I was able to achieve this.