View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Set color for chart serie in excel 2007/2010

I'm not sure I quite follow. Indeed the code is slightly different to apply
colour to Line or Fill but you say you have already got the code to do that.
The code is also slightly different in 2007+ and earlier versions.

For earlier versions have you considered making a workbook template for all
users with a customized palette. In particular customize the 6th row for
fill colours and the 7th row of 8 for line colours. If you do that all
charts will be automatically applied with your default colours (at least for
the first 8 series).

That approach is not useful in 2007. You can of course apply your own Office
theme. Colours are the same for fills and lines (unlike earlier versions).
Each set of series uses a different shade of them colour.

Another way is to defile your own palette, one way - (this assumes 2007)

- Colour format some cells, at least as many as there will ever be series in
a chart, Ctrl-F1, Fill, More colors..
- Name the coloured cells say "Swatch"

In your code that colours the series start with this

Dim pal() as long
getColors pal

and add this function

Sub getColors(pal() As Long)
Dim i As Long
Dim rng As Range, c As Range
Set rng = ActiveWorkbook.Names("Swatch").RefersToRange
ReDim pal(1 To rng.Count)
For Each c In rng
i = i + 1
pal(i) = c.Interior.Color
Next
End Sub


Do you know know to process each chart on each sheet?

Regards,
Peter T



"Lina" wrote in message
...
The company has a set of color and they dont allow any other colors. I
have done some chart templates with the predifined colors. The problem
is that if a user adds more data to a chart that is allready done the
new serie will not use the color that is saved in the chart template,
it uses the built in colors instead. Do get the right colors you can
apply the chart template again but, if the user has made som settings
for the chart thoose will be overriden by the template. So instead I
would like to have a button "set company color" and that button should
go thru the series and set the color that is allowed by the company. I
would like it to work for all type of charts. I have it working for
bar, line and pie but what if the user has made a bar and a line, is
there a way to get this to work for all chart types or must I treat
each type of serie differently?