PowerPoint Macro: Copying the Title Texts to the Speaker Notes

Sometimes I want to make speaker notes easily.
So I’ve made this PowerPoint VBA macro. This macro copies the title texts to the speaker notes on an active presentation.

Macro Example

Sub CopyTitleTextsToSpeakerNotes()

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld
    If .Shapes.HasTitle Then
      .NotesPage.Shapes.Placeholders(2).TextFrame.TextRange _
      = .Shapes.Title.TextFrame.TextRange
    End If
  End With
  Next sld

End Sub

Description

Variable Declaration

Sub...

  Dim sld As Slide

The 3rd line declares an object variable called sld that represent a Slide object.

The Slide object represent a single slide in a PowerPoint presentation.

obj-PowerPoint-Slide

Starts Looping

Sub...

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides

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

[Application.]ActivePresentation

  For Each sld In ActivePresentation...

The Application.ActivePresentation property returns an active Presentation object.

obj-PowerPoint-Application-ActivePresentation

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 ActivePresentation.Slides (Presentation.Slides property) returns a Slides collection object.

obj-PowerPoint-Presentation-Slides

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

obj-PowerPoint-Slides

Starts the With statement

Sub...

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld

The 6th line starts the With…End With statement.
This statement tells PowerPoint that following any action apply to the Slide object.

Checks If the Slide Has a Title

Sub...

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld
    If .Shapes.HasTitle Then

The 7th line checks if the slide has a title placeholder.

Slide.Shapes

  With sld
    If .Shapes...

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

obj-PowerPoint-Slide-Shapes

Shapes.HasTitle

  With sld
    If .Shapes.HasTitle Then

The Shapes.HasTitle property returns whether the Shapes collection objects on the slide contains a title placeholder.

obj-PowerPoint-Shapes-HasTitle

Copying the Title Texts to the Notes

Sub...

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld
    If .Shapes.HasTitle Then
      .NotesPage.Shapes.Placeholders(2).TextFrame.TextRange _
      = .Shapes.Title.TextFrame.TextRange

If a title placeholder is contained, the 8th-9th line copy a title text to a speaker note.

Well, the 8th line object model hierarchy is very deep.

      .NotesPage.Shapes.Placeholders(2).TextFrame.TextRange _

If you would like to understand this, please read this article. The 6th line in the removing speaker notes macro is the same object hierarchy.

And, I will explain about the 9th line.

      = .Shapes.Title.TextFrame.TextRange

Shapes.Title property

      = .Shapes.Title...

The Shapes.Title property returns a Shape object that represents the slide title.

obj-PowerPoint-Shapes-Title

Shape.TextFrame property

      = .Shapes.Title.TextFrame...

The Shape.TextFrame property (Title.TextFrame) returns a TextFrame object.

obj-PowerPoint-Shape-TextFrame

TextFrame.TextRange property

      = .Shapes.Title.TextFrame.TextRange

The TextFrame.TextRange property returns a TextRange object.

obj-PowerPoint-TextFrame-TextTrange

Because the Text property is a default property of the TextRange object, we can omit the Text property.

obj-PowerPoint-TextTrange-Text

So, the code
.Shapes.Title.TextFrame.TextRange is equal
.Shapes.Title.TextFrame.TextRange.Text .
It’s represents the title text.

Loops Back

Sub...

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld
    If .Shapes.HasTitle Then
      .NotesPage.Shapes.Placeholders(2).TextFrame.TextRange _
      = .Shapes.Title.TextFrame.TextRange
    End If
  End With
  Next sld

The 11th line ends the With…End With statement for the sld.
And the 12th line loops back to get the next slide.

After all the slide evaluated, this macro ends.

Sub CopyTitleTextsToSpeakerNotes()

  Dim sld As Slide

  For Each sld In ActivePresentation.Slides
  With sld
    If .Shapes.HasTitle Then
      .NotesPage.Shapes.Placeholders(2).TextFrame.TextRange _
      = .Shapes.Title.TextFrame.TextRange
    End If
  End With
  Next sld

End Sub

Properties

http://www.relief.jp/itnote/archives/001723.php

Applies To

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007