Changing shapes within groups (without ungrouping)
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.
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.
Dim oSh As Shape
Dim oSl As Slide
Dim X As Long
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
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!"
' Other Case statements as needed
End With ' oSh
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.