On 30/05/2011 21:26, Mark Mordeca wrote:
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”.

A few points:

* The underlying problem is almost certainly going to be a subtle
  timing interaction around the refcounting on the pywin32 CDispatch
  objects which are proxying for the underlying Windows objects.
  It's a maze of twisty passages, so I'll let Mark or Roger comment
  if they think there's something to be said.

* I couldn't reproduce the crash after a few times on my Win7 x64 with
  Office 2003, Python 2.7, pywin32 2.1.4. I note that you said it only
  crashed 1 time in 3 so perhaps I didn't try hard enough, but there
  may be some version-sensitivity there as well.

* In general, you don't need to go unsetting sheet or book or whatever
  (unless you have some requirement which is unstated here). If you
  get rid of the "sheet=None" etc. lines, does the crash still occur?

* As an aside: your for sheet in book.Sheets: loop is basically a
  list comprehension in disguise:

    sheetList = [sheet.Name for sheet in book.Sheets]

  Some people don't feel comfortable with list comps which may be your
  case. But just in case you weren't even aware of the possiblility, I
  thought I'd offer it for your further englightenment :)

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to