I am trying to copy three things from a PowerPoint slide and paste them into Word (using a VBA Marco in PowerPoint): 1) Slide number, 2) Thumbnail image of the slide, and 3) the Slide notes.
I'm able to grab the slide notes by using Placeholders(2)
, but I can't get the same approach to work when trying to copy the slide number placeholder on the slide. I can only get it working by providing the exact name of the shape 'Slide Number Placeholder 77'
.
I'm looking for pointers on how to copy the slide number placeholder on any arbitrary slide without having to know the exact name of the shape.
Thanks
Sub PPTtoWord()
' Copy slide 1, paste as picture onto slide 1, resize, and rename
ActivePresentation.Slides(1).Copy
Set mySlideCopy = ActivePresentation.Slides(1).Shapes.Paste
With mySlideCopy
.Name = "Slide Thumbnail"
.Left = 0
.Top = 0
.Height = 400
.Width = 200
End With
' Set up Word
Dim wdApp As Word.Application, wdDoc As Word.Document
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then Set wdApp = New Word.Application
Set wdDoc = wdApp.ActiveDocument
' Copy slide number from a placeholder on slide 1 over to Word
Set myDocument = ActivePresentation.Slides(1)
' ********** This is where the problem is *****************
ActivePresentation.Slides(1).Shapes("Slide Number Placeholder 77").TextFrame.TextRange.Copy
' *********************************************************
wdApp.Selection.PasteAndFormat wdFormatPlainText
wdApp.Selection.Move
' Copy slide thumbnail from slide 1 over to Word, then delete it
ActivePresentation.Slides(1).Shapes("Slide Thumbnail").Copy
wdApp.Selection.PasteAndFormat wdPasteDefault
wdApp.Selection.Move
ActivePresentation.Slides(1).Shapes("Slide Thumbnail").Delete
' Copy slide notes from slide 1 notes master over to Word
ActivePresentation.Slides(1).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Copy
wdApp.Selection.PasteAndFormat wdPasteDefault
wdApp.Selection.Move
End Sub
(Eventually I want to put these three things into a table and repeat for all slides, but I need to get this working first.)
`Dim oshp As Shape With ActivePresentation.Slides(1).Shapes Set oshp = .AddTextbox(msoTextOrientationHorizontal, 100, 100, 40, 20) oshp.TextFrame.TextRange.InsertSlideNumber ' oshp.Name = "Slide Num"' End With`
I then copy/paste Slide Num to Word and then delete the shape. – PMPM2000 May 25 '23 at 22:46