o0omax
08-03-2021, 02:42 AM
currently tis code does paste sth from excel into powerpoint. Unfortunately it creates a slides in the beginning of the presentation. How do I change the code, that it adds a slide and therefore copies the range from excel to a new slide which is placed after the current slide?
Sub copyRangeToPresentation()
' Open New PowerPoint Instance
Set pptApp = CreateObject("PowerPoint.Application")
With pptApp
' Activate exsting presentation
Set ppt = .ActivePresentation
' Add A Blank Slide
Set newSlide = ppt.Slides.Add(1, 12) ' ppLayoutBlank = 12
' Copy Range from Active Sheet in Excel
ActiveSheet.Range("A1:E10").Copy
' Paste to Powerpoint as an Image
newSlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
' Switch to PowerPoint
.Activate
End With
End Sub
Sub copyRangeToPresentation()
' Open New PowerPoint Instance
Set pptApp = CreateObject("PowerPoint.Application")
With pptApp
' Activate exsting presentation
Set ppt = .ActivePresentation
' Add A Blank Slide
Set newSlide = ppt.Slides.Add(1, 12) ' ppLayoutBlank = 12
' Copy Range from Active Sheet in Excel
ActiveSheet.Range("A1:E10").Copy
' Paste to Powerpoint as an Image
newSlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
' Switch to PowerPoint
.Activate
End With
End Sub