Ben
Ben

Reputation: 1

PowerPoint - Hide/Show Grouped Objects in Entire Presentation

I have a PowerPoint presentation with 156 slides. On each slide I have text boxes and shapes that I used the Group feature to band together then I labeled the group in the selection pane. I gave each group of shapes the same name on each slide. Right now the groups are visible on all of the slides, but there will times when these groups need to be hidden. Rather than going into each slide and manually hiding these groups via the selection pane, is there VBA I can add that would hide or show these groups in the entire presentation at once?

Update - I now have code that successfully shows and hides the specified shape group on the first slide when I run it:

Sub Numbers()

For i = 1 To 2

ActivePresentation.Slides(i).Shapes("Shape Group").Visible = msoTriStateToggle

Next

End Sub

To make this loop through the rest of the presentation, I added the following code:

Sub Numbers()

Dim sld As Slide

For Each sld In ActivePresentation.Slides

For i = 1 To 2
ActivePresentation.Slides(i).Shapes("Shape Group").Visible = 
msoTriStateToggle

Next

Next sld

End Sub

Now when I run this updated code, nothing happens. What's missing in this code?

Upvotes: 0

Views: 624

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

Your original code stepped through slides 1 - 2. You left that same loop in the modified code. Try this instead:

Sub Numbers()

Dim sld As Slide

For Each sld In ActivePresentation.Slides

sld.Shapes("Shape Group").Visible = msoTriStateToggle

Next sld

End Sub

Upvotes: 0

Related Questions