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