View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Vic Eldridge[_3_] Vic Eldridge[_3_] is offline
external usenet poster
 
Posts: 112
Default How to catch the colorindex in a series

Hi Peter,

I think we are seeing a version difference. I'm running Excel 2003 on
Windows XP, and the following routine paints each trendline the same color as
it's series. As the code shows, the series' are indeed colored using
xlColorIndexAutomatic.

Dim srs As Series
For Each srs In ActiveChart.SeriesCollection
With srs
.Border.ColorIndex = xlColorIndexAutomatic
.Trendlines(1).Border.Color = .Border.Color
End With
Next srs

Interestingly enough, if I try to read the color from the
..MarkerBackgroundColor or the .MarkerForegroundColor, I get the same
erroneous results as what you're describing.

The convoluted approach works fine on your, the OP's and my system, so I
guess we can conclude that it's the most reliable solution - until MS finally
decide to put XLM out to pasture. :-)


Regards,
Vic Eldridge


"Peter T" wrote:

Hi Vic,

Your suggestion certainly works if user has applied a palette colour, though
could just return the colorindex and use that if 1-56.

Unfortunately, and unless there's a version difference I'm unaware of,
returning border colour of a Line type series with xlAutomatic colour will
return system black, typically 0 pure black or whatever is set in user's
system for Window text.

This is despite the fact the actual colour will be "same as" say #25 if
first series.

I don't know any alternative other than along the lines of the convoluted
approach I suggested to the OP, or maybe GetPixelColor perhaps.

Regards,
Peter T

"Vic Eldridge" wrote in message
...
Hi Peter,

You're right. What I posted does not meet the OPs requirements.
I believe the following does though.

With ActiveChart.SeriesCollection(1)
.Trendlines(1).Border.Color = .Border.Color
End With


Regards,
Vic Eldridge


"Peter T" wrote:

I wasn't concentrating - Line Types do have a Fill property but both
..ForeColor & .Backcolor.Schemecolor return 70, and RGB colour 0,

whatever
the colour or colorindex of the Line.

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Vic,

This is neat if series are Fill types but from the OP's original post

he
appears to be working with Line types, which would not include a Fill
property

Regards,
Peter T

"Vic Eldridge" wrote in

message
...
With ActiveChart.SeriesCollection(1)
.Trendlines(1).Border.ColorIndex = .Fill.ForeColor.SchemeColor
End With

It's a pity they didn't stick to a single convention.


Regards,
Vic Eldridge


"leglouton" wrote:


Thanks for your feedback but I need of the actual colour. I want

to
add
to my series a trendline with the same color. If I apply the same
colorindex with xlautomatic, the colour is different. The property
colorindex from an object trendline set to xlautomatic give always

the
same color (black in my case) for each series.

leglouton

Peter T a écrit:
If all you want to do is colour your point to the same colour as

its
marker,
apply the same colorindex as returned from the marker, even if
xlautomatic.

You may want to ensure your point has a marker to avoid applying
xlNone,
effectively invisible, eg

x = .MarkerBackgroundColorIndex
if x = xlNone then x = xlAutomatic
myPoint.border.colorindex = x.

If you have only one series and vary colors by point, you would

need
to do
each point individually.

Come back if you need the actual automatic colour for some other
reason not
mentioned in your post.

Regards,
Peter T

"leglouton" wrote in message
...

How to catch the line or the point's color in an object serie

from a
chart when property is set to xlColorIndexAutomatic.

For example if My_series is a series object with his property
MarkerBackgroundColorIndex set to xlColorIndexAutomatic. How to
catch
the color give by Excel to fill the points of my series