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

error in excel generation using OLE

0 Likes
1,680

HI Experts,

i am using ole concept to download excel with multiple tabs(dynamic).

after the file is downloaded it is not having no of sheets specified.

i using below code

SET PROPERTY OF gv_excel 'SheetsInNewWorkbook' = lv_line.


can anyone help...?


thanks.

9 REPLIES 9
Read only

Former Member
0 Likes
1,521

For each new sheet that you require you should be using the method Sheets.Add on an OLE object that is a workbook.

To find out how to do things use the macro recorder in Excel and then translate the VBA to ABAP.

Regards

Rich

Read only

0 Likes
1,521

Use the below code to add new sheets

  GET PROPERTY OF gs_wbook 'Sheets' = gs_sheets .

  CALL METHOD OF gs_sheets 'Add' = gs_newsheet .

  SET PROPERTY OF gs_newsheet 'Name' = gv_sheet_name .

Also refer the below link for more commands

 

Read only

0 Likes
1,521

Isn't that what I just said ?

Read only

0 Likes
1,521

thanks for your suggestion.

i am using below code .


   CREATE OBJECT gv_excel 'EXCEL.APPLICATION'.

   SET PROPERTY OF gv_excel  'VISIBLE' = 0.

   CALL METHOD OF
       gv_excel
       'WORKBOOKS' = gv_workbook.

   CALL METHOD OF
       gv_workbook
       'ADD'.

   SET PROPERTY OF gv_excel 'SheetsInNewWorkbook' = lv_line_tmp.


sometimes i am getting number of sheets mentioned and sometimes i am getting only 2/3 sheets.


thanks for your help

Read only

0 Likes
1,521

Hi

The problem with OLE and excel is that when you use the 'QUIT' statement it does not actually quit Excel and you end up with hundreds of invisible excel instances running.  It may be that you have a problem with that when you are getting the 2/3 sheets only.  When this happens check in your task manager to see if that is the case.

Rich

Read only

0 Likes
1,521

thanks for your response.

so when we run the program which creates excel all the excel instances in background should be closed..?

thanks,

Phanindra

Read only

0 Likes
1,521

No,

I'm just pointing out that if you have been testing this all day you could have hundreds of instances running which could affect things.  I'm trying to remember how I killed them off...  let me think about that.

Read only

0 Likes
1,521

hello,

thanks for your help,

i am still facing this issue.

do you remember how to kill excel instance, for proper file creation.

thanks again...:)

Regards,

Phanindra G

Read only

0 Likes
1,521

Can't remember off of the top of my head,  you call the QUIT method.  Search the web - there's loads of stuff out there about this.

Rich