Hi,
I am trying to figure out how I can copy and paste all objects from a worksheet (including charts) onto a single Powerpoint slide and loop through sheets 1-4 (my sheets are named as "1", "2", "3", "4"). All content from sheet 1 should be pasted on slide 1 in the powerpoint, sheet 2 to slide 2 and so on. Copied objects should be pasted with paste special as pictures.
Here is my current code which pastes each chart onto an individual slide. Appreciate if I can get some help to adapt this to work as described above.
Code
Dim newPowerPoint As Object
Dim activeSlide As Object
Dim cht As Excel.ChartObject
'Look for existing instance
On Error Resume Next
Set newPowerPoint = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If newPowerPoint Is Nothing Then
Set newPowerPoint = CreateObject("PowerPoint.Application")
End If
If newPowerPoint.Presentations.Count = 0 Then
newPowerPoint.Presentations.Add
End If
newPowerPoint.Visible = True
For Each cht In ActiveSheet.ChartObjects
newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
cht.Select
ActiveChart.ChartArea.Copy
activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
' AppActivate ("Microsoft PowerPoint")
Set activeSlide = Nothing
Set newPowerPoint = Nothing
End Sub
Display More