PDA

View Full Version : [SOLVED:] Pasting copied slide into active presentation at current point



RandomGerman
06-22-2015, 02:27 AM
Hi all,

yesterday I realized, whenever I copy slides from one presentation to the active via VBA, I fit them in at the end of the presentation. So I tried out to hit the current position and found the solution below. But - whatever I did wrong then - today I get an error message marking "paste" and saying "View (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here." Although when I debug before testing the macro, all seems to be fine with the code.

It might be something ridiculous - could somebody please remove the black badge from my eyes? Thank you!


Sub PasteInCompleteSlides()
Dim src As Presentation
Dim trg As Slide
Dim shp As Shape
Dim target As Presentation

'Open the source presentation
Set target = Application.Presentations.Open("C:\Users\Chef\Desktop\MyFiles.pptx")
Set src = Presentations("MyFiles.pptx")

'Select and copy the slide
src.Slides(4).Copy

'Close the source presentation
With Application.Presentations("MyFiles.pptx")
.Close
End With

'Go back to active presentation and paste, then go to pasted slide
With ActiveWindow.View
.Paste
.GotoSlide (ActiveWindow.View.Slide.SlideIndex + 1)
End With

End Sub

RandomGerman
06-23-2015, 01:16 AM
It WAS something ridiculous! Sorry for posting before thinking.