[python-win32] Cannot assign values to the Excel Colors property

Graham Bloice graham.bloice at trihedral.com
Tue Aug 24 18:14:20 CEST 2004


> Thanks Niki!
>
> Nice try :).  I got an error message "TypeError: 'tuple' object is not
> callable".  I would think that the only way to do this would be to use the
> list assignment syntax.  I guess the COM interface doesn't support it
> though.  I'm sure there must be a way to do it.  I'm going to try
> writting a
> VB macro and then see if I can get Python to execute it. Then I'll delete
> the macro before I save the workbook.  It's kind of a round about
> way but it
> should get the job done until I can find out the right way to do it.
>
> Joe Goldthwaite
>
> -----Original Message-----
> From: Niki Spahiev [mailto:niki at vintech.bg]
> Sent: Tuesday, August 24, 2004 12:54 AM
> To: joe at goldthwaites.com
> Cc: Python-win32 at python.org
> Subject: Re: [python-win32] Cannot assign values to the Excel Colors
> property
>
>
> Joe Goldthwaite wrote:
> > Here's another strange one.  Automating Excel with Python is turning out
> to
> > be a little more difficult than I thought.  I'm trying to set the color
> > property of the workbook object. In VB it goes like this;
> >
> > Workbook.Colors(1) = &H254A70
> >
> > When I try doing this in Python, It complains about the syntax and tells
> me
> > I can't assign a value to a function call.  I also tried this;
> >
> > Workbook.Colors[1] = 0xH254A70
> >
> > But it tells me "TypeError: object doesn't support item
> assignment".  I'm
> > sure there's a way to do it but the syntax eludes me.  Anyone have any
> > ideas?
> >
>
> Maybe workbook.Colors(1, 0x223344) ?
>
> Niki Spahiev


try workbook.SetColors(1, xxx)

The Colors property of the Workbook interface is an indexed property, and
the Python COM support has to provide Setxxx and GetXXX methods to support
the indexing.  Have a look in the COM MakePy generated file for more info.

Graham



More information about the Python-win32 mailing list