0
votes

I'm currently working on PowerPoint VBA and writing a code to be able to copy the first slide and paste it again in the same presentation. However, I keep getting the error "Clipboard is empty or contains data which may not be posted here" and according to Microsoft page the problem is the use of "ActivePresentation"

I'm looking for another way to refer to the slide that I have open without using ActivePresentation. Any help? Ideas?

The line of code I use ActivePresentation is below:

ActivePresentation.Slides(1).Copy
ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count=1)

2
What Microsoft page are you referencing? By the way, is the = a typo? Seems like it.BigBen

2 Answers

2
votes

Don't copy, duplicate

Dim NewSlide as Slide
Set newSlide = ActivePresentation.Slides(1).Duplicate
NewSlide.MoveTo toPos:=4  'move it to become the fourth slide
1
votes

Slight variant on Harassed Dad's solution. PPT barks at the Set line because Duplicate returns a SlideRange object rather than a Slide object. .Duplicate(1) returns the first slide in the range as a Slide object. This duplicates slide 2 and moves it to the first position in the presentation.

Sub CopySlide()
    Dim oSl As Slide
    With ActivePresentation
        Set oSl = .Slides(2).Duplicate(1)
        oSl.MoveTo (1)
    End With
End Sub