07-13-2009 1:31 PM
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.
07-13-2009 1:42 PM
"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
07-14-2009 7:55 AM
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.
07-14-2009 8:06 AM
Hi shiva kumar,
Have checked the Version on Microsoft Excel coz ... this will not work with older verisons.
Regards,
Suneel G
07-14-2009 9:40 AM