Skip to Content
0
May 09, 2016 at 07:40 AM

Save and Close excel file copied through OLE

764 Views

Hi Experts,

I have copied an excel file then save it. But when i try to open the new excel, i cannot, i have message "excel is locked for editing by 'my user' ".

Here is my code:

CREATE OBJECT excel 'Excel.Application'.


SET PROPERTY OF excel 'VISIBLE' = 0.


CALL METHOD OF excel 'WORKBOOKS' = workarea.

CALL METHOD OF workarea 'OPEN'

EXPORTING

#1 = 'C:\excel1.xls'.


GET PROPERTY OF excel 'ACTIVEWORKBOOK' = workarea.


*copy sheet ELEUSIS1 -> sheet ELEUSIS1

CALL METHOD OF excel 'SHEETS' = work_copy

EXPORTING #1 = 'ELEUSIS1'.

CALL METHOD OF excel 'SHEETS' = workarea

EXPORTING #1 = 'ELEUSIS1'.


CALL METHOD OF workarea 'SAVEAS'

EXPORTING

#1 = 'C:\excel2.xls'.

#2 = 1.

CALL METHOD OF workarea 'close'.

* Quit the file

FREE OBJECT workarea.

CALL METHOD OF workarea 'QUIT'.

CALL METHOD OF excel 'QUIT'.

FREE OBJECT: excel.


Could you plz help me to close 'excel2'?

Thx.

Best regards,

Mehdi