1. Dennis Little
  2. PowerBuilder
  3. Wednesday, 7 February 2018 18:39 PM

All,

I'm opening an excel file and grabbing some cell info using ole.  The excel file isn't closing.  It isn't displayed in the menu tray.  The only way I know it's open is to try and open it.  Then I get the locked message saying I have it open and locked.

I'm on PB2017 Build 1681  32 bit.

I tried lole_excel.application.quit() and it seems to drop the lock, but I get the do you want to save? message.  Anyway to just close?

NOTE:  I just saw a post that suggested using the garbagecollect ( ) function, that didn't seem to work for me either.

if lb_exists = true then
               lole_excel= create oleobject
​               lole_excel.connecttonewobject("excel.application")
               lole_excel.workbooks.open(is_file)
               lole_worksheet = lole_excel.worksheets(1)
               ls_check = lole_worksheet.cells(5,1).value
               lole_excel.application.quit()
               lole_excel.disconnectobject()
               destroy lole_excel
               /*process the ls_check value…*/
else
               messagebox('Error', 'Cannot find file!')
end if

Accepted Answer
Dennis Little Accepted Answer Pending Moderation
  1. Friday, 9 February 2018 13:44 PM
  2. PowerBuilder
  3. # Permalink
0
Votes
Undo

This did he trick!  Thanks Ricardo!

 

Ricardo Colarina's picture

Hi Dennis,

To prevent the Save changes messagebox from popping, can you try adding the following before quit:

lole_excel.ActiveWorkbook.Saved = true

Cheers,

Ricardo

Comment
There are no comments made yet.
Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 7 February 2018 19:09 PM
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Hi Dennis,

 

I think this post may have the answer you are looking for: https://community.appeon.com/index.php/qna/q-a/excel-oh-my-excel-why-you-hate-me

 

In sum, by adding a garbagecollect() into the code some users fixed it.

 

I hope this helps.

 

Regards,

Comment
Thanks Govinda,



I actually used parts of that post to get my code working.  I have added the garbagecollect() call and that does not work for me.

The only thing that seems to work is the lole_excel.application.quit() call, but it pops up the Save changes messagebox, which I'd like to get rid of.



 



Thanks



 

  1. Dennis Little
  2. Wednesday, 7 February 2018 19:54 PM
Hi Dennis,



To prevent the Save changes messagebox from popping, can you try adding the following before quit:



lole_excel.ActiveWorkbook.Saved = true



Cheers,



Ricardo

  1. Ricardo Colarina
  2. Wednesday, 7 February 2018 20:42 PM
Ricardo,



That did the trick! 



Plug that in as answer and I'll mark it as the BEST answer.



Thanks

  1. Dennis Little
  2. Thursday, 8 February 2018 14:00 PM
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.