VBA - from Excel to Powerpoint
I'm trying to make a code work (see below). I have a saved excel and powerpoint file. I'm trying to paste individual excel data to individual powerpoint slides, for instance A3 to slide 3, A4 to slide 4, etc. The errors I get is mostly at "oPPSlide.Shapes.Paste.Select": either integer out of range or object is not active/found. What am I doing wrong here? Does it have something to do with the current slide not being active or the shape not defined (enough)?
Thanks in advance for all replies.
Dim oPPApp As Object, oPPPrsn As Object, oPPSlide As Object
Dim oPPShape As Object
Dim FlName As String
Dim i As integer
'~~> Change this to the relevant file
FlName = "C:\Test.PPTM"
'~~> Establish an PowerPoint application object
On Error Resume Next
Set oPPApp = GetObject(, "PowerPoint.Application")
If Err.Number <> 0 Then
Set oPPApp = CreateObject("PowerPoint.Application")
On Error GoTo 0
oPPApp.Visible = True
'~~> Open the relevant powerpoint file
Set oPPPrsn = oPPApp.Presentations.Open(FlName)
For i=3 to ThisWorkbook.Sheets("RMs").Range("A65000").end(xlup).row
'~~> Change this to the relevant slide which has the shape
Set oPPSlide = oPPPrsn.Slides(i)
'~~> Write to the shape
ThisWorkbook.Sheets("RMs").Range("A" & i).CopyPicture Appearance:=xlScreen, _
'~~> Rest of the code