Python/Excel VBComponents crash
Mark Hammond
mhammond at skippinet.com.au
Fri Aug 8 22:02:59 EDT 2003
Mark Carter wrote:
> I use Office 2000, and I have recently upgraded to python 2.3 and
> win32all-155.exe
>
> The following code worked in python 2.2:
>
> xlApp = Dispatch("Excel.Application")
> xlApp.Visible = 1
> xlApp.Workbooks.Add()
> xlApp.ActiveWorkbook.SaveAs(sys.path[0] + '\\temp.xls')
> wb = xlApp.Workbooks("temp.xls")
> wbc = wb.VBProject.VBComponents # <---- CAUSES CRASH IN 2.3
> xlApp.Quit()
> del xlApp
>
> but I get a GPE in 2.3, when the code finishes execution:
> EXCEL caused an invalid page fault in
> module OLE32.DLL at 0167:65f18ae3.
>
I think this is a bug in Excel, but it is not clear why Python 2.3 shows
it, but 2.2 does not. If you set wbc to None before closing, it doesn't
crash. I think the problem is that Excel doesn't like being shut down
when references to it still exist. You should try and make sure that
pythoncom._GetInterfaceCount() returns zero before quitting.
Mark.
More information about the Python-list
mailing list