• PowerPoint macro: Copy text from slide text to slide notes area

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » PowerPoint macro: Copy text from slide text to slide notes area

    Author
    Topic
    #499062

    I want to copy the text from PowerPoint slides to the notes section of the PowerPoint.

    If there are 2 shapes with text – I want to copy both, appending the text in the notes section.

    I tried the code below —but am getting an error message on “curNotes = curSlide.NotesPage.Shapes(1).”

    Please help! :confused:

    Code:
    Dim curPres As PowerPoint.Presentation
    Dim curSlide As Slide
    Dim curShape As Shape
    Dim curNotes As Shape
    
    
    
    
    For Each curSlide In ActivePresentation.Slides
    
        For Each curShape In curSlide.Shapes
            If curShape.TextFrame.HasText Then
                 curShape.TextFrame.TextRange.Copy
                 curNotes = curSlide.NotesPage.Shapes(1)
                 curNotes.TextFrame.TextRange.Paste
            End If
    
        Next curShape
    
    Next curSlide
    
    
    End Sub
    
    
    
    Viewing 0 reply threads
    Author
    Replies
    • #1495842

      There is probably a more efficient way to do this but this appears to work

      Code:
      Sub GoGetEm()
        Dim curSlide As Slide
        Dim curShape As Shape
        Dim curNotes As Shape
        Dim oSh As Shape
        
        For Each curSlide In ActivePresentation.Slides
          For Each oSh In curSlide.NotesPage.Shapes
            If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
              Set curNotes = oSh
              Exit For
            End If
          Next oSh
          For Each curShape In curSlide.Shapes
            If curShape.TextFrame.HasText Then
              curNotes.TextFrame.TextRange.InsertAfter curShape.TextFrame.TextRange.Text & vbCr
            End If
          Next curShape
        Next curSlide
      End Sub
      • #1495861

        This works GREAT! Many thanks!

        Except there are two small problems — it also copies the slide title and the page number. Is there any way to identify these elements so I can skip coping them?

        • #1495890

          It is possible that we can work out what type of object the text comes from but without seeing the actual presentation file I can’t be sure it would work.

          The fact that you can isolate the placeholderformat.type on the notes page would imply that you could do the same on the slide itself but I have seen lots of powerpoint files with random text boxes used on the page instead of slide master placeholders. Try to add an if statement inside the curShape loop to verify the placeholderformat is not title or pagenumber types.

    Viewing 0 reply threads
    Reply To: PowerPoint macro: Copy text from slide text to slide notes area

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: