VBA - from Excel to Powerpoint
Hi all,
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.
"
Option Explicit
Sub Test()
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")
End If
Err.Clear
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, _
Format:=xlPicture
oPPSlide.Shapes.Paste.Select
'
'~~> Rest of the code
'
End Sub
"
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago