This worked! Thank you all that replied
Rafael Copquin On 10/06/2016 19:09, Richard Kaye wrote:
The Excel object probably is waiting for you to ask it if you want to save any unsaved changes but the dialog is not being displayed. If you set the saved property of the active workbook to true before you call the Quit event, that should clear things up. m.loExcel.ActiveWorkbook.Saved= .T. && this prevents Excel prompt when we destroy the Excel object Another thing you can try to do if you want to dig into why the Excel object is in an odd state is make it visible in your error handler before you call the quit event. -- rk -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of Mike Copeland Sent: Friday, June 10, 2016 5:28 PM To: [email protected] Subject: Re: Excel automation Here's a snippit of code I have been using with great success recently. I wish I remembered where it came from but it is the best way to terminate a Windows application that I've found. I use it to close the application if it is left running by the end user. It simply tests to see if the # of seconds since midnight is greater than a predefined # of seconds. For your need, I don't think you'd need the time check. Hope this helps! LOCAL loLocator, loWMI, loProcesses, loProcess, llIsRunning loLocator = CREATEOBJECT('WBEMScripting.SWBEMLocator') loWMI = loLocator.ConnectServer() loWMI.Security_.ImpersonationLevel = 3 loProcesses = loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE Name = 'MyApplicationName.exe']) FOR EACH loProcess in loProcesses loProcess.Terminate(0) ENDFOR Mike Copeland rafael copquin wrote:I've been using the following technique to open an instance of Excel for years: If Upper(Vartype(Thisform.oExcel)) = "O" Thisform.oExcel.Quit Thisform.oExcel = null Else Thisform.AddProperty('oExcel') Endif If Upper(Vartype(Thisform.oExcel)) <> "O" Thisform.oExcel=Createobject("Excel.Application") Else Thisform.oExcel=Getobject(,"Excel.Application") Endif The above is taken from the Hacker's Guide However, sometimes Excel throws an error. Therefore in my form class error method I put this construct: If nError = 1426 && Excel error If Vartype(thisform.oExcel ) = "O" thisform.oExcel.quit Thisform.oExcel = null endif endif Yet, it does not kill the Excel instance. I mean, the Excel instance is still open. It just does not go away. The only way to kill it is to open the task manager and kill it manually I follow the Excel method step by step, and reproduce the error condition. The error method fires, the oExcel object exists, the line "thisform.oExcel.quit" executes, but it does not kill the Excel instance ???????? 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.

