win32com_garbage collection, another QTN
zzzzz
zzizz_ at notmail.com
Mon Apr 23 02:26:09 EDT 2001
On Mon, 23 Apr 2001 02:12:56 GMT, Mark Hammond <MarkH at ActiveState.com>
wrote:
>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.
Thanks Mark,
You don't get author's responding directly to questions in many NGs :)
I'm just getting a handle (pun unintended) on win32com at the moment,
I'll check out your suggestion.
As for the code I call up:
x = state.Range("a2:c2").Value and more of the like.
I did notice that after the post that
>> state.Workbooks.Open("G:\\MH_State_Flow_7.xls")
returns an workbook object by entering it on the interactive window,
maybe I need to capture this and close it first. I think
"pythoncom._GetInterfaceCount()" might be very useful for debugging
this sort of this.
Regards,
zzzzz.
---------------------
More information about the Python-list
mailing list