PDA

View Full Version : Change color of only the selected shape in a group



clhare
07-28-2016, 05:38 AM
I use the following code to change the color of the selected shape to 100% black:


Sub Black100()
With ActiveWindow.Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0#
End With
End Sub


But if the selected shape is part of a group, the whole group changes color. How can I modify this to only change the selected shape within that group?

Your help is greatly appreciated!

Cheryl

John Wilson
07-28-2016, 05:43 AM
and no transparency are the defaults so:


Sub groupy()
On Error Resume Next
If ActiveWindow.Selection.HasChildShapeRange Then
With ActiveWindow.Selection.ChildShapeRange
.Fill.ForeColor.RGB = RGB(0,0,0)
End With
End If
End Sub

clhare
07-28-2016, 06:27 AM
This is perfect! Thank you so much!

Cheryl

clhare
07-28-2016, 08:31 AM
Oh! One more question... how would I alter that macro to change the text color of just that one shape (leaving the background as is)?

John Wilson
07-28-2016, 08:59 AM
You don't say what version of Office but this will work in most versions.


Sub groupyText()
On Error Resume Next
If ActiveWindow.Selection.HasChildShapeRange Then
If ActiveWindow.Selection.ChildShapeRange(1).HasTextFrame Then
With ActiveWindow.Selection.ChildShapeRange(1)
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0)
End With
End If
End If
End Sub

clhare
08-03-2016, 05:05 AM
Ok, so this works on shapes. Is it possible to do the same thing with selected parts of a chart? Change the fill/background color of only the selected plot area, chart area, data series, bar segment, etc.?

John Wilson
08-03-2016, 07:16 AM
Sadly it isn't. Charts do not have childshaperanges! I have had this discussion with MSFT several times - they should!! In Excel it is easy but not in PPT.

clhare
08-03-2016, 07:25 AM
Ok thanks for letter me know. It would definately have been nice if it was possible to do.

John Wilson
08-03-2016, 08:02 AM
Trust me it's big problem for me too. Clients just don't believe it cannot be done.