Copy text from an Excel text box to PowerPoint notes section

jerH

Board Regular
Joined
Dec 3, 2008
Messages
168
I know how to write literal text, or the contents of a string variable into the notes section of a powerpoint slide. But how can I capture the text that's in an Excel textbox in order to do the same?

If I record a macro when copying the text out of a textbox I get something like this

Code:
ActiveSheet.Shapes.Range(Array("NotesBox")).Select
    Range("P35").Select
    ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
        False

And here's some sample code for writing into the notes section

Code:
Sub AddNotestoPP()
    Dim Sl As Slide, Sh As Shape, strNotesPageText As String
  
    strNotesPageText = "This Text will go in the notes area"
    
    Set Sl = ActivePresentation.Slides(1)
    
    [COLOR=green][B]'~~> If no shapes to take Notes then add a shape first[/B][/COLOR]
    If Sl.NotesPage.Shapes.Count = 0 Then
        Sl.NotesPage.Shapes.AddShape msoShapeRectangle, 0, 0, 0, 0
        Sh = Sl.NotesPage.Shapes(1)
        Sh.TextFrame.TextRange.Text = strNotesPageText
    [COLOR=green][B]'~~> If the ppt has shapes then see if they take text[/B][/COLOR]
    Else
        For Each Sh In Sl.NotesPage.Shapes
            If Sh.HasTextFrame Then
                Sh.TextFrame.TextRange.Text = strNotesPageText
                Exit For
            End If
        Next Sh
    End If
End Sub

But I'm not sure how to make the leap to connect them...
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Disregard, I (mostly) got it...though I do still have one issue.

This code
Code:
If PPSlide.NotesPage.Shapes.Count = 0 Then
                     PPSlide.NotesPage.Shapes.AddShape msoShapeRectangle, 0, 0, 0, 0
                     PPshape = PPSlide.NotesPage.Shapes(1)
                     PPshape.TextFrame.TextRange.Text = ws.Shapes.Range(Array("NotesBox")).TextFrame2.TextRange.Text
                 '~~> If the ppt has shapes then see if they take text
            Else
                     For Each PPshape In PPSlide.NotesPage.Shapes
                              If PPshape.HasTextFrame Then
                                       PPshape.TextFrame.TextRange.Text = ws.Shapes.Range(Array("NotesBox")).TextFrame2.TextRange.Text
                                       Exit For
                             End If
      Next PPshape
 End If

gets there, as noted in the OP, with one change.

If I declare the variable PPshape as type shape, I get a type mismatch error in the For Each PPshape In PPSlide.NotesPage.Shapes loop. To make it work, I have to declare PPshape as a variant...?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top