J
John Coleman
Greetings,
I created an Excel 2000 macro to allow a user to try out different
colors for the line in an XY-chart series. The key code fragment was
If MySeries.Border.ColorIndex = 56 Then
MySeries.Border.ColorIndex = 1
Else
MySeries.Border.ColorIndex = MySeries.Border.ColorIndex + 1
End If
I attached the macro to a button and start clicking to see the result.
It worked well for a while - then disappeared! Forever. Evidently the
following is true: for series 1 , the automatic ColorIndex is 25
(though in my test graph I had started with ColorIndex 1). When the
code bumped the ColorIndex to 25, Excel reset the colorindex to 57
(and *not* -4105, which would have been annoying but would have made
sense since xlColorIndexAutomatic = -4105).
Now things get wierd: after the colorindex was set to 57, the next
time the macro fired it tried to bump it to 58. No runtime error is
thrown but the effect is to make the series appear to disappear *and*
to reset the colorindex to 57. If you click on the invisible series to
view its formatting the format dialog box itself suggests that the
line should be visible (it isn't that the line has been set to none,
which is what happens if you set the ColorIndex to xlColorIndexNone).
Firing the macro further at this stage just stays trapped in ghost
index 57/58. Curiously, ColorIndex 59 seems to be an alias for 1, but
60 finally throws an error.
At first I hypothesized that charts were using just 1 byte for the
colorindex, but if you explicitly set the ColorIndex to
xlColorIndexAutomatic and afterwards ask it to msgbox the ColorIndex
it displays -4105 and not 57.
I've already made my own work-around, but this behavior is strange.
Are there any other Excel objects that have undocumented ColorIndices?
-John Coleman
I created an Excel 2000 macro to allow a user to try out different
colors for the line in an XY-chart series. The key code fragment was
If MySeries.Border.ColorIndex = 56 Then
MySeries.Border.ColorIndex = 1
Else
MySeries.Border.ColorIndex = MySeries.Border.ColorIndex + 1
End If
I attached the macro to a button and start clicking to see the result.
It worked well for a while - then disappeared! Forever. Evidently the
following is true: for series 1 , the automatic ColorIndex is 25
(though in my test graph I had started with ColorIndex 1). When the
code bumped the ColorIndex to 25, Excel reset the colorindex to 57
(and *not* -4105, which would have been annoying but would have made
sense since xlColorIndexAutomatic = -4105).
Now things get wierd: after the colorindex was set to 57, the next
time the macro fired it tried to bump it to 58. No runtime error is
thrown but the effect is to make the series appear to disappear *and*
to reset the colorindex to 57. If you click on the invisible series to
view its formatting the format dialog box itself suggests that the
line should be visible (it isn't that the line has been set to none,
which is what happens if you set the ColorIndex to xlColorIndexNone).
Firing the macro further at this stage just stays trapped in ghost
index 57/58. Curiously, ColorIndex 59 seems to be an alias for 1, but
60 finally throws an error.
At first I hypothesized that charts were using just 1 byte for the
colorindex, but if you explicitly set the ColorIndex to
xlColorIndexAutomatic and afterwards ask it to msgbox the ColorIndex
it displays -4105 and not 57.
I've already made my own work-around, but this behavior is strange.
Are there any other Excel objects that have undocumented ColorIndices?
-John Coleman