That's become a standard part of my exception handling with COM stuff. If I catch any kind of error, I check to see if the Word or Excel object is in scope and make it visible.
-- rk -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of rafael copquin Sent: Friday, October 21, 2016 5:36 PM To: [email protected] Subject: Re: Excel errors I solved it! What I did was make the oExcel object _visible_ just after instantiation and before trying to open the file. if upper(vartype(thisform.oExcel)) <> "O" thisform.oExcel=createobject("Excel.Application") else thisform.oExcel=getobject(,"Excel.Application") endif thisform.oExcel.visible = .T. Try lOK = .t. With thisform.oExcel .workbooks.open("&cExcel") endwith etc Thank you all anyways Rafael On 21/10/2016 18:09, Richard Kaye wrote: > You've probably got some hidden dialog waiting for an answer asking you if > you want to save your changes. Try adding something like this to your > exception handling before you call Quit. > > m.oExcel.ActiveWorkbook.Saved= .T. && this prevents Excel prompt when we > destroy the Excel object > > -- > > rk > -----Original Message----- > From: ProfoxTech [mailto:[email protected]] On Behalf Of rafael > copquin > Sent: Friday, October 21, 2016 4:59 PM > To: [email protected] > Subject: Excel errors > > 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/bn4pr10mb09130c7b92962bee828684fed2...@bn4pr10mb0913.namprd10.prod.outlook.com ** 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.

