Color problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set the color on a shape object to the same color as the
border color for a series object. I want to execute a statement akin to:

shLI.Line.ForeColor.SchemeColor =
ActiveChart.SeriesCollection(i).Border.ColorIndex

I know the above code fails but how can I translate the Border.ColorIndex to
an identical color permitting setting of SchemeColor? Any help appreciated.
 
Have you tried

shLI.Line.ForeColor.SchemeColor =
ActiveChart.SeriesCollection(i).Border.Color

--

HTH

RP
(remove nothere from the email address if mailing direct)


ojv said:
I am trying to set the color on a shape object to the same color as the
border color for a series object. I want to execute a statement akin to:

shLI.Line.ForeColor.SchemeColor =
ActiveChart.SeriesCollection(i).Border.ColorIndex

I know the above code fails but how can I translate the Border.ColorIndex to
an identical color permitting setting of SchemeColor? Any help
appreciated.
 
Yes. It results in an out of range error.

Bob Phillips said:
Have you tried

shLI.Line.ForeColor.SchemeColor =
ActiveChart.SeriesCollection(i).Border.Color

--

HTH

RP
(remove nothere from the email address if mailing direct)



appreciated.
 
Following worked for me. With a line (shape) embedded on a chart and
selected:

Sub test()
Dim shLI As ShapeRange, cx as long, i

Set shLI = Selection.ShapeRange

i = 1 ' guess "i" is in a loop

cx = ActiveChart.SeriesCollection(i).Border.ColorIndex

If cx = xlAutomatic Then cx = i + 24

shLI.Line.ForeColor.SchemeColor = cx + 7
End Sub

Unless otherwise formated, coloured series lines will be xlautomatic, with
colours same as those from colorindex 25 and on, in series index order. Add
7 to convert to schemcolor.

Regards,
Peter T
 
Solves it. Thx.

Peter T said:
Following worked for me. With a line (shape) embedded on a chart and
selected:

Sub test()
Dim shLI As ShapeRange, cx as long, i

Set shLI = Selection.ShapeRange

i = 1 ' guess "i" is in a loop

cx = ActiveChart.SeriesCollection(i).Border.ColorIndex

If cx = xlAutomatic Then cx = i + 24

shLI.Line.ForeColor.SchemeColor = cx + 7
End Sub

Unless otherwise formated, coloured series lines will be xlautomatic, with
colours same as those from colorindex 25 and on, in series index order. Add
7 to convert to schemcolor.

Regards,
Peter T
 
Glad it works, should have mentioned that the relationship between series
index and colorindex 25 on only works in a "typical" chart, several factors
could upset this. If necessary apply the Color (not colorindex) as some cell
color format, the applied colour will be mapped to the nearest colorindex,
then return and apply that colorindex to your line (+7).

Regards,
Peter T
 
Thx. again. Will keep in mind. Some times the way colors work out in Excel do
not appear entirely logical, at least to me.

ojv
 

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

Back
Top