Greetings,
I would appreciate any help I could get with the following problem. 30% of
the time after running the following code to get the sheet names out of an
excel file, I will receive a windows error saying that “Microsoft Office
Excel has stopped working”.
Code:
xl=win32com.client.DispatchEx("Excel.Application")
book=xl.Workbooks.Open(filename)
sheetList=[]
for sheet in book.Sheets:
sheetList.append(sheet.Name)
sheet=None # get rid of reference to sheet
try:
book.Close()
book=None
xl.Quit()
except:
print "getting sheet names exception!"
book=None
xl.Quit()
xl=None
return sheetList
The sheetList variable is returned fine, the print in the except statement
does not appear and the program can continue as normal, however the
following Windows error appears:
Microsoft Office Excel has stopped working
Windows can check online for a solution to the problem
->Check online for a solution and close the program
->Close the program
->Debug the program
Problem Details:
*Problem signature:*
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 12.0.6550.5004
Application Timestamp: 4d2cee93
Fault Module Name: ntdll.dll
Fault Module Version: 6.1.7601.17514
Fault Module Timestamp: 4ce7ba58
Exception Code: c0000005
Exception Offset: 00038da9
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
*Additional information about the problem:*
LCID: 1033
Brand: Office12Crash
skulcid: 1033
While the program can continue as normal, to users using the program, having
this error popup and having to click “close the program” is not acceptable.
Can anyone help me with a reason as to why I get this error message (and
only sometimes at that) even though no exception is thrown and I retrieved
the sheet names perfectly fine? Is there a way to suppress this error from
even appearing (though not ideal and it is a windows error not an Excel
error so I don’t think this is possible)?
I thank you for any assistance.
Mark
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32