[python-win32] AtributeError with long opening Excel files

Jacek Jablonski yacek87 at gmail.com
Mon Jan 31 22:44:45 CET 2011


Hi,
I have got a problem with code that opens my Excel workbook and try to
perform some operations:
self.app = Dispatch('Excel.Application')
self.app.Workbooks.Open('someexcel.xls')
print(self.app.ActiveWorkbook.Sheets('test').Range('D4'))

I receive AttributeError, but I know what caused it. My workbook has
pivot tables that are refreshed on workbook opening, so it takes some
time to open and Workbook.Open() function returns immediatly without
waiting. If I add some time.sleep() between 2nd and 3rd line, it works
fine.

What is the best way to solve this problem? Are there any other ways
to open workbook (sync open)? Is there any way to detect if file is
fully opened?

Cheers,
Jacek


More information about the python-win32 mailing list