PPTools
Shape Styles brings the power of styles to PowerPoint. Apply complex formatting with a single click
Merge Excel, CSV or tab-delimited data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more
FixLinks prevents broken links when you distribute PowerPoint presentations
Optimizer saves disk space and bandwidth, shrinks your PowerPoint presentations to the right size for email, screenshow or printing
PPT2HTML gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements
Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF
Image Export converts PowerPoint slides to JPG, PNG, GIF, WMF and more
|
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
|
Contents © 1995-2008 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
|
|