win32com_garbage collection, another QTN

zzzzz zzizz_ at notmail.com
Sun Apr 22 19:23:40 EDT 2001


Hi all,

Someone else mentioned a similar question a while ago though I can't
find it in google groups, I think the exact question was about
winword.

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

## 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.

Is this an example of python garbage collecting when it wants?
If it is the should there be a better way to disassociate the COM
application other that del?


Regards,

zzzzz.
---------------------



More information about the Python-list mailing list