[python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

Graham Bloice graham.bloice at trihedral.com
Tue Jul 17 17:31:04 CEST 2012


> -----Original Message-----
> Subject: Re: [python-win32] new Pywin32 errors stating 'object has no
> attribute' - and the code worked previously
>
> On 17/07/2012 16:05, Kurt Munson wrote:
> > Dunno exactly what you mean by "what's your Dispatch code look like".
>
> Well pretty much what you posted, in fact :)
>
> > Incidentally, I tried changing the dispatch line to use dynamic
> > dispatch using this code:
> >
> > <code> xl = win32com.client.dynamic.Dispatch("Excel.Application")
> > </code>
> >
> > ...and I still run into apparent case sensitivity, like not
> > recognizing xl.visible, in lower case.  I thought dynamic dispatch
> > would remove case sensitivity.
>
> So did I:
>
> <dump>
> ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1
> (r271:86832, Feb  7 2011, 11:30:38) [MSC v.1500 32 Type "help",
"copyright",
> "credits" or "license" for more infor
> >>> import win32com.client
> >>> xl = win32com.client.dynamic.Dispatch("Excel.Application")
> >>> xl.visible
> False
> >>> xl.Visible
> False
> >>>
> >>>
>
> </dump>
>
> whereas:
>
> <dump>
> >>> xl2 = win32com.client.gencache.EnsureDispatch("Excel.Application")
> >>> xl2.visible
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "c:\python27\lib\site-packages\win32com\client\__init__.py", line
462,
> in __getattr__
>     raise AttributeError("'%s' object has no attribute '%s'" %
(repr(self), attr))
> AttributeError: '<win32com.gen_py.Microsoft Excel 11.0 Object
> Library._Application instance at 0x58072680>' object has no attribute
'visible'
> >>>
> </dump>
>
>
> Well I'm stumped. Hopefully someone more knowledgeable can chip in.
>
[Graham Bloice said]

Maybe remove the generated early binding .py for Excel in win32com\gen_py


More information about the python-win32 mailing list