win32com_garbage collection, another QTN
Mark Hammond
MarkH at ActiveState.com
Sun Apr 22 22:12:56 EDT 2001
zzzzz wrote:
...
> My problem is excel, and getting it to close properly:
>
> ---------------------------------------------------------
> import win32com.client
>
>
> state=win32com.client.Dispatch("Excel.application")
> state.Workbooks.Open("G:\\MH_State_Flow_7.xls")
> state.Visible=1
>
What goes in here is suspect :)
> ## read stuff from excel worksheet without modifying file
>
> state.Visible=0
> state.Quit() # This is what was suggested to the previous QTN
> del state
> ----------------------------------------------------------
>
> According to what I've read, this sequence of quit commands should
> close excel (even without the .Quit command). To all appearances this
> is true, however, when I look at the task manager (I'm using NT4.0sp6)
> good old excel.exe is still running. The only way to close it cleanly
> (that I know of) is to close the interpreter.
There is a good chance you still have a COM reference left alive.
Check what pythoncom._GetInterfaceCount() returns, and if non-zero you
have another reference - probably the document or worksheet object.
Mark.
More information about the Python-list
mailing list