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: 

Save and Close excel file copied through OLE

former_member1167366
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

I don't understand what you're trying to achieve with the 2 lines CALL METHOD OF excel 'SHEETS', especially the second one is problematic as you change workarea. Could you remove them, and try again?

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos

I don't understand what you're trying to achieve with the 2 lines CALL METHOD OF excel 'SHEETS', especially the second one is problematic as you change workarea. Could you remove them, and try again?

0 Kudos

thanks