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: 

Unable to open downloaded Excel file using OLE

Former Member
0 Kudos

Hi Experts,

I am downloading data from internal table to an Excel template using OLE. After downloading the data into excel file, i am using SAVEAS option to save the file in the given PATH with new FILENAME. Up to this, it is working fine. After saving the file, i am unable to open the saved file. To get it opened, i need to open any other excel file before and then close the file. Then this new file opened automatically. Can any body help me how to over come this problem. i think some thing wrong with my code which i am using to close the documents. Heres my code.

  • Fill Sheet1 data

  • Populating data from internal table to Excel cells

PERFORM fill_sheet1 USING xv_lifnr xv_adrnr xv_bukrs.

  • Save excel speadsheet to particular filename

GET PROPERTY OF gv_application 'ActiveWorkBook' = gv_workbook.

CALL METHOD OF gv_workbook 'SAVEAS'

EXPORTING

#1 = gv_fullpath

#2 = 1. "fileFormat

SET PROPERTY OF gv_application 'DisplayAlerts' = 0.

  • Closes excel window, data is lost if not saved

SET PROPERTY OF gv_application 'visible' = 0.

CALL METHOD OF gv_sheet 'CLOSE'.

    • Quit the file

CALL METHOD OF gv_sheet 'QUIT'.

CALL METHOD OF gv_workbook 'CLOSE'.

CALL METHOD OF gv_workbook 'QUIT'.

CALL METHOD OF gv_application 'CLOSE'.

    • Quit the file

CALL METHOD OF gv_application 'QUIT'.

FREE OBJECT: gv_application, gv_workbook, gv_sheet, gv_cells,

gv_range, gv_font, gv_parform.

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

"Quit" method only exists for "application" object, but it does not explain the problem. How do you start excel?

Edited by: Sandra Rossi on Jul 13, 2009 2:43 PM

0 Kudos

Hi Sandra,

I have an excel template and i am opening the excel template using below code

CREATE OBJECT gv_application 'EXCEL.APPLICATION'.

SET PROPERTY OF gv_application 'Visible' = 1.

CALL METHOD OF gv_application 'Workbooks' = gv_workbook.

CALL METHOD OF gv_workbook 'OPEN'

EXPORTING

#1 = p_pxls.

0 Kudos

Hi shiva kumar,

Have checked the Version on Microsoft Excel coz ... this will not work with older verisons.

Regards,

Suneel G

0 Kudos

Yes Suneel,

I am using Excel 2009.