0

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.)

Ken White
  • 123,280
  • 14
  • 225
  • 444
PMPM2000
  • 3
  • 3
  • Unless you have some unusual numbering, you can simply use the .SlideIndex property for the slide, it's normally identical to the slide number. https://learn.microsoft.com/en-us/office/vba/api/powerpoint.slide.slideindex – John Korchok May 25 '23 at 15:49
  • Thanks! I was able to solve it with:
    `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

0 Answers0