win32com.client problem

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


Hi,

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
http://www.faqts.com/knowledge_base/entry/versions/index.phtml?aid=5847
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
stage:
ActiveComConn = pythoncom._GetInterfaceCount()
print 'Done! Active Com Connections :',ActiveComConn # Print count of
Active COM connections.

Thank you,
--Kartic




More information about the Python-list mailing list