A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Charts and Charting in Excel
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How do I use VBA to change line colors



 
 
Thread Tools Display Modes
  #1  
Old June 2nd 05, 10:37 PM
Dilbert00
external usenet poster
 
Posts: n/a
Default How do I use VBA to change line colors


I have a multi-series 2-D line chart. Each series is a different color,
but these colors appear to be chosen automatically, and are not the
colors I want to use.

I've tried this:

GraphObj.SeriesCollection(2).Interior.Color = RGB(255, 180, 0)

But this generates the error "Unable to set the Color property of the
Interior class."

So, where in the depths of the object model can I go to change the
color of the lines? And if you can tell me that, I'll bet you can also
tell me where to go to change the width or thickness of a line, too.

Any help is very much appreciated.


--
Dilbert00
------------------------------------------------------------------------
Dilbert00's Profile: http://www.excelforum.com/member.php...o&userid=23993
View this thread: http://www.excelforum.com/showthread...hreadid=376141

Ads
  #2  
Old June 3rd 05, 09:01 AM
Andy Pope
external usenet poster
 
Posts: n/a
Default

Hi,

For a line you would need,

GraphObj.SeriesCollection(2).Border.Color = RGB(255, 180, 0)

and for other formatting try these instead of Color.
.Weight = xlMedium
.LineStyle = xlContinuous

Using the macro recorder is a good way of getting this syntax.

You can change the automatic colours for charts. Use the menu Tools >
Options. On the Color tab is a section for chart lines and fills.

Cheers
Andy

Dilbert00 wrote:
> I have a multi-series 2-D line chart. Each series is a different color,
> but these colors appear to be chosen automatically, and are not the
> colors I want to use.
>
> I've tried this:
>
> GraphObj.SeriesCollection(2).Interior.Color = RGB(255, 180, 0)
>
> But this generates the error "Unable to set the Color property of the
> Interior class."
>
> So, where in the depths of the object model can I go to change the
> color of the lines? And if you can tell me that, I'll bet you can also
> tell me where to go to change the width or thickness of a line, too.
>
> Any help is very much appreciated.
>
>


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change multi-line entries to single line entries in Exce. CPOWEREQUIP Excel Worksheet Functions 3 April 14th 05 12:38 AM
How do I change background colors between secondary y axis lines? myhounds Charts and Charting in Excel 2 March 28th 05 01:11 AM
In mixed bar and line chart. I cannot change one of my source da. bluetractorboy Charts and Charting in Excel 1 January 21st 05 03:17 PM
In mixed bar and line chart. I cannot change one of my source da. bluetractorboy Charts and Charting in Excel 0 January 21st 05 02:57 PM
How do I change the colour of/remove the Freeze Panes line in Exce katya_1978 Excel Worksheet Functions 1 January 20th 05 06:17 PM


All times are GMT +1. The time now is 08:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 ExcelBanter.
The comments are property of their posters.