MCardol
02-17-2016, 01:41 AM
Hi all,
I'm trying to make a code work in Excel 2013 (see below). I have a saved excel and powerpoint file. I'm trying to paste individual excel data to individual powerpoint slides that already exist, for instance A3 to slide 3, A4 to slide 4, etc. The errors I get are mostly at "oPPSlide.Shapes.Paste.Select": either integer out of range or shape 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
'~~> The relevant ppt 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 ppt 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
I'm trying to make a code work in Excel 2013 (see below). I have a saved excel and powerpoint file. I'm trying to paste individual excel data to individual powerpoint slides that already exist, for instance A3 to slide 3, A4 to slide 4, etc. The errors I get are mostly at "oPPSlide.Shapes.Paste.Select": either integer out of range or shape 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
'~~> The relevant ppt 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 ppt 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