[python-win32] COM access to Excel suddenly stopped working
sjmachin at lexicon.net
sjmachin at lexicon.net
Thu Apr 21 02:36:41 CEST 2005
On 19 Apr 2005 at 14:52, Mark Hammond wrote:
> Hi John,
>
> > (1) xl = win32com.client.Dispatch("Excel.Application")
> > (2) print repr(xl)
> > (3) xlwb = xl.Workbooks.Open(filename)
> >
> > Before, line 2 would print this:
> > <win32com.gen_py.Microsoft Excel 10.0 Object
> > Library._Application instance at
> > 0x39073872>
> > and line 3 would work OK.
> >
> > Now, line 2 prints this:
> > <COMObject Excel.Application>
>
> That is strange - the script is not finding the makepy generated file. This
> could be due to the gen_py directory being removed - by default you should
> find it in lib\site-packages\win32com\gen_py
>
> Using win32com.client.gencache.EnsureDispatch() in place of Dispatch should
> force that generation - but I'm afraid I have no idea why it suddenly became
> necessary.
Hello again, Mark.
A bit of an update:
Not a problem with makepy. The gen_py directory was intact. Re-running makepy didn't
solve the problem.
What I was doing was exploratory programming i.e. [look at VBAXL10.CHM, scratch
head, edit, run, exception] * n where n was a large number. I wasn't doing xl.Quit() even
when it didn't crash. Next run after an exception, it would pop up a dialog box saying
that the XLS file was already open and did I want to discard changes? I also discovered
when I finally shut down all my windows that there was a dialog I'd never noticed before,
about saving files. My guess is that one of more of the above caused Excel to exceed
some resource limit and then run amok.
Cheers,
John
More information about the Python-win32
mailing list