[python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ?

Bob Gailer bgailer at sbcglobal.net
Wed Jun 29 21:24:24 CEST 2005


At 05:16 AM 6/29/2005, Fabrice Capiez wrote:
>Thank you Gabriel and Tim
>
>Indeed the Chart.Location was causing a problem, and I had not suspected it
>was since I do not use this method in my main program (It was just something
>  I had written as an example). Actually, it seems that the Copy method of
>either a chart or a sheet is also corrupting the original objects which thus
>  cannot be congigured correctely after. In the case of Copy it is even more
>annoying since the copy itself is not perfect : some axis labels erradically
>  disappear during the process.
>Well, at least I now have a way of continuing my project thanks to you. (I
>would have prefered to stick to the copy method since opening and copying a
>sheet with all the charts pre-formated takes only half a second whereas
>generating 11 charts and setting the appearence takes about 4 seconds.. but
>well, it's better than nothing)
>
>Thankyou once again then,
>
>Fabrice Capiez
>
>
>Tue, 28 Jun 2005 07:43:50 -0300 $B:"$K(B
>$B!X(BRe: [python-win32] Unable to set an Excel chart's titlethrough 
>win32com :
>can you reproduce this problem ?$B!Y$NCf$G(B
>Gabriel Genellina <gagenellina at softlab.com.ar> $B$5$s$O=q$-$^$7$?(B:
>
> > At Tuesday 28/6/2005 06:03, Capiez Fabrice wrote:
> >
> > >chart.Location (Where=constants.xlLocationAsObject,
> > >Name=sheet.Name)
> > >try:
> > >     chart.HasTitle = True
> > >     chart.ChartTitle.Characters.Text ="title"

According to Excel Visual Basic Help: "Characters - Returns a 
<mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\Office\1033\VBAXL9.CHM::/html/xlobjCharacters.htm>Characters 
object that represents a range of characters within the object text. You 
can use the Characters object to format characters within a text string.

Now look at the Text property "Returns or sets the text for the specified 
object. Read-only String for the Range object, read/write String for all 
other objects."

So try chart.ChartTitle.Text ="title"

> > >
> > >The following produces:
> > >
> > >Excel failed with code -2146827864: OLE error 0x800a01a8
> > >No extended information
> > >
> > >The same error occurs if I try to set an axis title
> > >instead of the chart's title. It also occurs whether I
> > >first set chart.HasTitle to True or not. I
> >
> > Error 800a01a8 is "Object required"
> > The error is triggered by the chart.HasTitle line, before setting the 
> title
> > text.
> > So I guessed, chart does not point to a valid object on that line.
> > Commenting out the previous line chart.Location(...) solved the problem.
> > I was unable to find documentation on the Location() method, but I guess
> > that moving the chart to another sheet invalidates the object reference
> > (which may be tied to its current location...)
> >
> >
> > Gabriel Genellina
> > Softlab SRL
>__________________________________
>Save the earth
>http://pr.mail.yahoo.co.jp/ondanka/
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32

Bob Gailer
mailto:bgailer at alum.rpi.edu
510 558 3275 home
720 938 2625 cell  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050629/da7b585d/attachment-0001.htm


More information about the Python-win32 mailing list