PDA

View Full Version : Solved: Trigger background color change on shape?



TrippyTom
03-01-2007, 05:01 PM
Is there a way to trigger a macro when a shape's background color is set? The reason I was wondering is I'd like to automatically:
- change the text to black if it's a light background, or ...
- change the text to white if it's a dark background

TrippyTom
03-01-2007, 05:29 PM
By the way, I was hoping to utilize this formula to determine the White/Black values:
http://www.codeproject.com/cs/media/IdealTextColor.asp

I just need to know if I can use the macro as some sort of trigger, or if I should do it on all shapes on the current slide, or something.

TrippyTom
03-02-2007, 10:24 AM
Well, I decided to go at this from a different perspective. Since we use very specific colors at work (a template), I decided to just change it to a subset of only those colors, so I know if the text should go white or black automatically.

If anyone knows of a way to trigger this whenever a fill color is changed, I'd still like to know just for learning purposes.

TrippyTom
03-02-2007, 12:45 PM
How would I turn this into a CASE statement?


With ActivePresentation.Slides(mySlide).Shapes
If .Range.HasTextFrame Then
If .Range.Fill.ForeColor.RGB = RGB(255, 255, 255) Then
.Range.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)
End If


... NEVERMIND :)
I figured it out.

For Each shp In ActivePresentation.Slides(mySlide).Shapes
If shp.HasTextFrame Then
Select Case shp.Fill.ForeColor.RGB
Case Is = RGB(255, 255, 255) 'white
shp.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)