How to convert RGB color to scheme color?

H

Hooyoo

I insert a chart in the excel. The chart style is AreaStacked. There
are 3 series in the SeriesCollection. I don't like the default colors
of the series, so I want to set Series.Fill.ForeColor to change the
color of series. But the type of Series.Fill.ForeColor is
SchemeColor, I don't konw how to set the value. Does anybody know the
relationship between RGB and SchemeColor? Thanks.
 
S

Steve Rindsberg

Hooyoo said:
I insert a chart in the excel. The chart style is AreaStacked. There
are 3 series in the SeriesCollection. I don't like the default colors
of the series, so I want to set Series.Fill.ForeColor to change the
color of series. But the type of Series.Fill.ForeColor is
SchemeColor, I don't konw how to set the value. Does anybody know the
relationship between RGB and SchemeColor? Thanks.

I mostly work in MSGraph where this is even loopier, but in Excel you need to
change the color palette.

Manually: Tools, Options, Color tab, click the palette chip you want to work
with and click Modify. Choose your new color or enter an RGB value there.

You need to change a palette color and then assign that color's index to
whatever you want to recolor. IIRC, you can do something like:

Series.Fill.ForeColor.RGB = RGB(111,222,111)

and Excel will choose the color that comes closest off the palette. IOW, it
won't error, it won't ignore you exactly, but neither will it do what you asked
it to.
 
H

Hooyoo

I mostly work in MSGraph where this is even loopier, but in Excel you need to
change the color palette.

Manually: Tools, Options, Color tab, click the palette chip you want to work
with and click Modify. Choose your new color or enter an RGB value there.

You need to change a palette color and then assign that color's index to
whatever you want to recolor. IIRC, you can do something like:

Series.Fill.ForeColor.RGB = RGB(111,222,111)

and Excel will choose the color that comes closest off the palette. IOW, it
won't error, it won't ignore you exactly, but neither will it do what you asked
it to.

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

Hi, buddy, Series.Fill.ForeColor.RGB is readonly property. I can't do
that.
 
S

Steve Rindsberg

Hi, buddy, Series.Fill.ForeColor.RGB is readonly property. I can't do
that.

As I explained, you can't do it anyhow.
Here. This demonstrates it:

Sub WatchThis()

' This sets position 7 in the palette to the color we want:
ActiveWorkbook.Colors(7) = RGB(0, 111, 0)

With ActiveSheet.ChartObjects("Chart 1").Chart
With .SeriesCollection(1).Interior

' set it to the index that you've just set to be the color you want
.ColorIndex = 7

' but if you set it to a specific color
.Color = RGB(0, 100, 0)
' Excel remaps it to one of the colors on its palette
' In short, you can't do that

End With
End With

End Sub
 
H

Hooyoo

As I explained, you can't do it anyhow.
Here. This demonstrates it:

Sub WatchThis()

' This sets position 7 in the palette to the color we want:
ActiveWorkbook.Colors(7) = RGB(0, 111, 0)

With ActiveSheet.ChartObjects("Chart 1").Chart
With .SeriesCollection(1).Interior

' set it to the index that you've just set to be the color you want
.ColorIndex = 7

' but if you set it to a specific color
.Color = RGB(0, 100, 0)
' Excel remaps it to one of the colors on its palette
' In short, you can't do that

End With
End With

End Sub

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================- Hide quoted text -

- Show quoted text -

Thank you. got it ^_^
 

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