[python-win32] Excel Workbooks Exception

Mark Mordeca mark.mordeca at prosensus.ca
Fri Jan 31 16:08:00 CET 2014


Hello,



I sometimes get a random exception when trying to open an Excel file.  It
is not consistent.  I will get the exception, and then try it again and it
will work fine.



Simple two lines of code:



xl=win32com.client.DispatchEx("Excel.Application")

book=xl.Workbooks.Open(self.__filename, ReadOnly=True)



where self.__filename is a path to an Excel file.



The exception I get is:

<type 'exceptions.AttributeError'>:  Excel.Application.Workbooks



It's very confusing because

1.  I will get the exception, try it again, and it will work fine.

2.  How is it even possible to Dispatch successfully but then it not have a
core attribute like Workbooks?



Any insight is greatly appreciated.

Thanks,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140131/3c2559b5/attachment.html>


More information about the python-win32 mailing list