'PowerPoint VBA select slide

My goal is to creat ppt via VBA. I have already the template in my desktop that i need to use. This part of the code is ok.

However I did not find how to select slides in the ppt. I try many ways and i get all the times error.

If someone could help me.

Option Explicit

Sub CreatePowerPoint()

Dim mySlide As PowerPoint.Slide
Dim myShapeRange As PowerPoint.Shape

Dim oPA As PowerPoint.Application
Dim oPP As PowerPoint.Presentation
Dim oPS As PowerPoint.SlideRange
Dim strTemplate As String
Dim rng As Range

strTemplate = "C:\Users\290866\Desktop\vba\PPT\Template.potx"

Set oPA = New PowerPoint.Application
oPA.Visible = msoTrue
oPA.Presentations.Open strTemplate, untitled:=msoTrue

If Not oPS Is Nothing Then Set oPS = Nothing
If Not oPP Is Nothing Then Set oPP = Nothing
If Not oPA Is Nothing Then Set oPA = Nothing


Err_PPT:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
Resume Next
End If

Set rng = ThisWorkbook.Sheets("Credit Recommendation").Range("B2:N59")

ActivePresentation.Slides (1)
  rng.Copy
mySlide.Shapes.PasteSpecial (ppPasteBitmap)
  Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count)
myShapeRange.LockAspectRatio = msoFalse
      myShapeRange.Left = 20
      myShapeRange.Top = 80
      myShapeRange.Height = 400
 myShapeRange.Width = 680
  Application.CutCopyMode = False


End Sub

Thank you!!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source