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

Kurt Munson kurt.munson at hbmncode.com
Tue Jul 17 17:05:14 CEST 2012


Dunno exactly what you mean by "what's your Dispatch code look like".

If you mean what am I doing with Excel via Python, it's like this:  it creates an Excel spreadsheet, adds a bunch of content, formats cells, etc.  All of this worked beautifully until this morning.

Here is a little bit of the code I am using to control Excel:

<code>
import win32com.client
xl = win32com.client.DispatchEx("Excel.Application")

# other stuff

xl.DisplayAlerts = 0
xl.Visible = 0

# more other stuff

currentSheet.Range("A1:B1").EntireColumn.AutoFit

# more more other stuff

plotbutton = currentSheet.buttons.Add(300, 8, 80, 45)
</code>

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.

-Kurt


-----Original Message-----
From: Tim Golden [mailto:mail at timgolden.me.uk]
Sent: Tuesday, July 17, 2012 10:27 AM
To: Kurt Munson; python-win32 at python.org
Subject: Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously

[cc-ing the list back in so you get the benefit of more and greater intelligences...]


On 17/07/2012 15:20, Kurt Munson wrote:
> I don't get it: I haven't made any changes to that Dispatch call in
> months!
>
> My code worked for months with the existing Dispatch method, up
> through yesterday afternoon, then began returning errors this morning.
> How could this be?


Well maybe I'm wrong. Someone else might have a better idea, but it's a classic symptom of this issue. What does your Dispatch code look like?

TJG

Confidentiality Notice: This email may contain confidential and/or privileged information. If you are not the intended recipient of this message, please delete it immediately and inform the sender that you have received this message in error.


More information about the python-win32 mailing list