[python-win32] Best Way to 'Dispose' of COM / Excel
Tom Churm
churmtom@hotmail.com
Wed, 05 Jun 2002 16:27:10 +0200
hi,
i'm using python & COM on Win32 to create Excel files using
'win32com.client.dynamic'.
i've tried to research the best way to close Excel at the end of my script,
but, once in awhile, Excel still freezes or crashes (this happens maybe only
10% of the time).
my question: is there a better way to close Excel and 'dispose' of my COM
stuff at the end of my script, so that when something goes wrong in the
running of the script, etc., Excel will not crash or act strangely?
here's what i'm using now:
=============================================
ExcelApp=win32com.client.dynamic.Dispatch("Excel.Application")
ExcelApp.Visible = 0
workbook = ExcelApp.Workbooks.Add()
...
workbook.SaveAs(Filename=thePath + "\\" + strExcelFileName + ".xls")
workbook.Close(0)
ExcelApp.Quit()
ExcelApp = None
=============================================
thanks much in advance!
tom
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com