Instead of trying to open your XLS file via Excel Automation, just try
opening it via a ShellExecute call.
hth,
--Mike
On 2016-10-21 16:59, rafael copquin wrote:
I have been using Excel automation for years. However, I could not
find a way to kill the Excel application when an error occurs.
Here is an example:
I have this cursor with an inventory list that contains 9000 rows and
10 columns, named curStock.
I save the cursor with:
local cExcel
cExcel = 'c:\temp\stock.xls'
select curStock
copy to (cExcel) type xl5
if upper(vartype(thisform.oExcel)) = "O"
thisform.oExcel.quit
thisform.oExcel = .f.
Else
thisform.AddProperty('oExcel')
EndIf
if upper(vartype(thisform.oExcel)) <> "O"
thisform.oExcel=createobject("Excel.Application")
else
thisform.oExcel=getobject(,"Excel.Application")
endif
Try
lOK = .t.
With thisform.oExcel
.workbooks.open("&cExcel")
endwith
Catch to oError
lOK = .f.
MessageBox(oError.message,16,'Excel caused an error',2000)
thisform.oExcel.quit
EndTry
if not lOK
quit
else
*** show the spreadsheet
endif
The property thisform.oExcel is trying to open the big Excel sheet
(stock.xls) but fails
Supposedly thisform.Excel.quit should kill the Excel instance.
However it still remains in memory. The task manager shows it is still
dangling in memory but is invisible.
How can I kill it?
BTW I use this approach instead of filling and formatting the sheet
line by line, because it takes about half an hour to show, due to the
large amount of records the cursor contains.
Rafael Copquin
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.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.