WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

change series or line color in excel 2007 vba

 
   Home -> Office -> Charting RSS
Next:  Charts Excel 2003  
Author Message
Nick

External


Since: Mar 31, 2006
Posts: 146



(Msg. 1) Posted: Thu Jan 24, 2008 10:34 am
Post subject: change series or line color in excel 2007 vba
Archived from groups: microsoft>public>excel>charting (more info?)

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???
Back to top
Login to vote
Jon Peltier

External


Since: Mar 19, 2004
Posts: 2776



(Msg. 2) Posted: Thu Jan 24, 2008 2:28 pm
Post subject: Re: change series or line color in excel 2007 vba [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This works:

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

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Nick" <Nick DeleteThis @discussions.microsoft.com> wrote in message
news:914D6B2D-86C1-42D7-9BD9-3C8534CBBD4E@microsoft.com...
> 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???
Back to top
Login to vote
Nick

External


Since: Mar 31, 2006
Posts: 146



(Msg. 3) Posted: Thu Jan 24, 2008 2:28 pm
Post subject: Re: change series or line color in excel 2007 vba [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

"Jon Peltier" wrote:

> This works:
>
> objSeries.Border.Color = RGB(255, 127, 0)
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> Peltier Technical Services, Inc. - http://PeltierTech.com
> _______
>
>
> "Nick" <Nick.TakeThisOut@discussions.microsoft.com> wrote in message
> news:914D6B2D-86C1-42D7-9BD9-3C8534CBBD4E@microsoft.com...
> > 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???
>
>
>
Back to top
Login to vote
Andy Pope

External


Since: Feb 27, 2004
Posts: 638



(Msg. 4) Posted: Thu Jan 24, 2008 7:52 pm
Post subject: Re: change series or line color in excel 2007 vba [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

Nick wrote:
> 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.
>
> "Jon Peltier" wrote:
>
>
>>This works:
>>
>> objSeries.Border.Color = RGB(255, 127, 0)
>>
>>- Jon
>>-------
>>Jon Peltier, Microsoft Excel MVP
>>Tutorials and Custom Solutions
>>Peltier Technical Services, Inc. - http://PeltierTech.com
>>_______
>>
>>
>>"Nick" <Nick DeleteThis @discussions.microsoft.com> wrote in message
>>news:914D6B2D-86C1-42D7-9BD9-3C8534CBBD4E@microsoft.com...
>>
>>>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???
>>
>>
>>

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Charting All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support