title: Modify Excel VBA code to paste into specific ppt slides
body: <p>I am new to the forum, and a few months new to VBA. All my coding experience is in Matlab, which so far I find much easier than VBA. I have read the forum rules, and searched for this answer high and low, but to no avail.</p>
  
  <p>I am trying to paste different excel ranges into different slides of a PowerPoint. I want to modify the code below (taken in snipets from different forum answers) so that the range is pasted into the corresponding PowerPoint slide I denote, <strong>regardless of what the active slide is.</strong> I have tried "gotoslide" and that didn't work, and used ppviewnormal, but that also didn't work. This code will then be repeated for different ranges on different slides. So far the code will only work when I am on the slide it was written for, and I know it has to do with issues regarding the active slide, but cannot seem to figure out how to modify the code. Thank you in advance for your help!</p>
  
  <pre><code>' Desired Range in Excel to be copied into ppt
    Sheets("Summary").Activate
    Range("A5:H40").Select
  
  ' Initialize PowerPoint Object Library
  Set PPApp = GetObject(, "Powerpoint.Application")
  ' Reference active presentation
  Set PPPres = PPApp.ActivePresentation
  PPApp.ActiveWindow.ViewType = ppViewSlide
  ' Denote slide where range is to be copied
  Set PPSlide = PPPres.Slides(5)
  
  ' Copy the range as a picture
  Selection.CopyPicture Appearance:=xlScreen, _
      Format:=xlPicture
  
  ' Paste the range
  PPSlide.Shapes.Paste.Select
  </code></pre>