change series or line color in excel 2007 vba

N

Nick

I've done this hundreds of times in 2003, but in 2007 I'm hitting some snags.
I think it has to do with the chart styles found in excel 2007. I'm trying
to change the color of a series in my line graph using the following code:

Set ch = Worksheets("Chart").ChartObjects(1)
Set objSeries = ch.Chart.SeriesCollection(1)

objSeries.Format.Line.ForeColor.RGB = RGB(255, 127, 0)

But, this isn't working at all. Nothing is happening to the line. I'm able
to do other things to the series, such as change the marker style, the marker
color, the line style, but not the line color.

Any ideas???
 
N

Nick

Thanks!! That worked. One more question. Do you happen to know why the
border object does not show up when using intellisense in the VBA window of
Excel 2007? That makes it seem as though the border object has been removed
from the 2007 object model.
 
A

Andy Pope

Hi,

In VBE press F2 to display object browser. Right click and pick Show
Hidden Members. Border is now there.

Also did you notice how Jon's suggested work around then makes your line
of code work! If you step through the code you should see the line go
black and then Orange, or what ever your colour is.

objSeries.Border.Color = RGB(0, 0, 0)
objSeries.Format.Line.ForeColor.RGB = RGB(255, 127, 0)

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top