win32com.client problem

Kartic kartic.krishnamurthy at
Wed Jan 5 15:05:11 EST 2005


1. Put your COM invokations in a try/except loop. From my experience,
that helped me prevent, in most cases, Excel from "hanging" and having
to restart the PC too. In the except part, release the Excel (or other
COM resource) (e.g.calling workbook.Close() or excelobj.Quit(),
depending on the state of your program)

2. Look at
to see how to get the actual error.

3. Delete instances of the COM connection, RS object or whatever
win32com.client instances you create. I do this:
sheetobj = None
wbkbobj = None
excelobj = None
del sheetobj
del wbkobj
del excelobj

4. At the end of my scripts, I do the following during the development
ActiveComConn = pythoncom._GetInterfaceCount()
print 'Done! Active Com Connections :',ActiveComConn # Print count of
Active COM connections.

Thank you,

More information about the Python-list mailing list