With Excel 2003...
I'm using this line to set the text color (forecolor) of a checkbox:
Me.chkDynoHP.ForeColor = Sheets("Preferences").Range("colorDynoHP").Interior.Color
I use a custom function to set the color of some chart entities to this same color:
With Sheets("Dyno").ChartObjects("DynoGraph").chart
.Axes(xlValue).TickLabels.Font.ColorIndex = ColorIndexOfOneCell(Range("colorDynoHP"), False, True)
...
...
End With
Function ColorIndexOfOneCell(Cell As Range, OfText As Boolean, DefaultColorIndex As Long) As Long
Dim CI As Long
Application.Volatile True
If OfText = True Then
CI = Cell(1, 1).Font.ColorIndex
Else
CI = Cell(1, 1).Interior.ColorIndex
End If
If CI < 0 Then
If IsValidColorIndex(ColorIndex:=DefaultColorIndex) = True Then
CI = DefaultColorIndex
Else
CI = -1
End If
End If
ColorIndexOfOneCell = CI
End Function
The basic idea here is that the checkbox controls the display of a graph series, and the user can select the color for the series, which includes the checkbox text, series line color, and axis display. Everything works fine, except the checkbox ForeColor property doesn't always update to the correct color. In fact, it seems random and doesn't make any sense at all. It doesn't seem to matter if I update the colors in Deactivate on the "Preferences" page, Activate on the "Dyno" page, or anywhere else; sometimes the checkbox forecolor updates, and sometimes it doesn't. I have several checkboxes on two separate sheets that all show this same behavior.
I'm not loading other palettes or anything else, so I don't understand why it isn't updating to the correct color.
Any ideas?
Bookmarks