PowerPoint Macro: Unhiding All Placeholders

This PowerPoint VBA macro unhides or shows all the placeholders in an active presentation.

Macro Example

Sub ShowAllPlaceholders()

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders
      shp.Visible = msoTrue
    Next shp
  Next sld

End Sub

Description

Variable Declaration

The 3rd line declares an object variable called sld refers to a Slide object.

Sub...

  Dim sld As Slide

The Slide object represents an individual slide in a PowerPoint presentation.

obj-PowerPoint-Slide

The 4th line declares an object variable called shp refers to a Shape object.

Sub...

  Dim sld As Slide
  Dim shp As Shape

The Shape object represents a placeholder, shape, freeform, OLE object or picture.

obj-PowerPoint-Shape

Starts Looping Through All Slides

The 6th line starts to loop through all the elements (sld = Slide) of a collection (ActivePresentation.Slides).

Sub...

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides

(Applications.)ActivePresentation

  For Each sld In ActivePresentation...

The Application.ActivePresentation property returns an active Presentation object.

obj-PowerPoint-Application-ActivePresentation

And, the ActivePresentation property is a member of the PowerPoint.Global class, so we can omit the Application property.

obj-PowerPoint-ActivePresentation

ActivePresentation.Slides (Presentation.Slides)

  For Each sld In ActivePresentation.Slides

The Presentation.Slides property (ActivePresentation.Slides) returns a Slides object.

obj-PowerPoint-Presentation-Slides

The Slides object is a collection of all the Slide object in a presentation.

obj-PowerPoint-Slides

Starts Looping Through All Shapes

The 7th line starts to loop through all the elements (shp = Shape) of a collection (sld.Shapes.Placeholders = Shapes).

Sub...

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders

Slide.Shapes (sld.Shapes)

The Slide.Shapes property (sld.Shapes) returns a Shapes collection object that represents all the shapes that have been placed on a slide.

    For Each shp In sld.Shapes...

obj-PowerPoint-Slide-Shapes

Shapes.Placeholders

The Shapes.Placeholders property returns a Placeholders object. The Placeholders is a collection of all the Shape objects that represent placeholders.

    For Each shp In sld.Shapes.Placeholders

obj-PowerPoint-Shapes-Placeholders

And, its individual object is a Shape object that represents a single placeholder.

obj-PowerPoint-Placeholders-Item

Unhides a Placeholder

The 8th line unhide the placeholder by the Shape.Visible property.

Sub...

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders
      shp.Visible = msoTrue

The Shapes.Visible property returns or sets the visibility of a shape.

obj-PowerPoint-Shape-Visible

Loops Back

The 9th line loops back to get the next Shape object.

Sub...

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders
      shp.Visible = msoTrue
    Next shp

The 10th line loops back to get the next Slide object.

Sub...

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders
      shp.Visible = msoTrue
    Next shp
  Next sld

After each placeholder is unhidden, this macro ends.

Sub ShowAllPlaceholders()

  Dim sld As Slide
  Dim shp As Shape

  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes.Placeholders
      shp.Visible = msoTrue
    Next shp
  Next sld

End Sub

Properties

http://www.relief.jp/itnote/archives/powerpoint-vba-show-all-placeholders.php

Apply to

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007