Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF

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


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2015 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.
Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Changing shapes within groups (without ungrouping)
http://www.pptfaq.com/FAQ00600_Changing_shapes_within_groups_-without_ungrouping-.htm
Last update 07 June, 2011
Created: