Changing shapes within groups (without ungrouping)
Problem
You have a macro that needs to do something to every shape in a presentation. It's working fine, except when you run into a shape that's a group. You need some way to get at the shapes within the group.
Solution
As an example, here's a bit of code that will replace all of the text in shapes within groups.
With a few mods, you could have it changing colors or most anything else.
Sub ReplaceTextInGroup()
Dim oSh As Shape
Dim oSl As Slide
Dim X As Long
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
With oSh
Select Case .Type
Case Is = msoGroup
For X = 1 To .GroupItems.Count
If .GroupItems(X).HasTextFrame Then
If .GroupItems(X).TextFrame.HasText Then
' Obviously, you'd run your own replace code here:
.GroupItems(X).TextFrame.TextRange.Text = "HA! Gotcha!"
End If
End If
Next X
' Other Case statements as needed
End Select
End With ' oSh
Next oSh
Next oSl
End Sub
Limitations
This code won't look at groups within groups.
You can't delete or add shapes within groups, only change their properties.
See How do I use VBA code in PowerPoint? to learn how to use this example code.
Search terms:group,shape