I read Microsoft Office Automation with Visual FoxPro by Tamar Grainor 
and others, ages ago, and it has been very useful to me over the years.

However, there is something I could never get to work and it is this:

suppose that for some reason an error occurs in your application while 
the Excel object has been instantiated and the worksheet is not visible.

IOW, I write code like this:

thisform.oExcel=createobject("Excel.Application")

a cursor is scanned, its records are placed in a worksheet and when 
everything is done, I issue the command:

thisform.oExcel.visible = .t.

But, if an error occurs while scanning the cursor, the form has code to 
exit immediately from VFP, sending the error message to an error log, etc.

However, the Excel object is standing there and, because it is not 
visible, the user is not aware of this. Subsequent calls to the Excel 
method in the form will not work, depending on the Excel version the 
user has installed in his/her machine and he could end up having two or 
more instances of Excel dangling in memory, pus her machine "frozen".

I try to issue this command:

if pemstatus(thisform,'oExcel',5) = .t. && the excel property exists
    if vartype(thisform.oExcel) = 'O' && Excel is instatiated and alive
      thisform.oExcel.quit()
    endif
endif

But it does not work, it does not kill the Excel instance. It has to be 
done by hand using the Windows Task Manager.

How should I code the error routine to kill the Excel instance when 
there is any error (Excel generated or form generated) ?


TIA

Rafael Copquin



--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to