title: Pasting Excel Chart into PowerPoint Slide
body: <p>The below Sub is supposed to paste an Excel chart into a newly created PowerPoint slide. It then exports the chart as a PNG:</p>
  
  <pre><code>Sub ChartsToPowerPoint()
  
      Dim pptApp As PowerPoint.Application
      Dim pptPres As PowerPoint.Presentation
      Dim pptSlide As PowerPoint.Slide
  
      'Open PowerPoint and create an invisible new presentation.
      Set pptApp = New PowerPoint.Application
      Set pptPres = pptApp.Presentations.Add(msoFalse)
  
      'Set the charts and copy them to a new ppt slide
  
      Set objChart = Worksheets("Sheet1").ChartObjects("Chart 1").Chart
      objChart.ChartArea.Copy
      Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
      pptSlide.Shapes.PasteSpecial DataType:=ppPasteDefault, Link:=msoFalse
  
      'Save Images as png
      path = "C:\Users\xyz\Desktop\"
  
      For j = 1 To pptSlide.Shapes.Count
          With pptSlide.Shapes(j)
              .Export path &amp; j &amp; ".png", ppShapeFormatPNG
          End With
      Next j
  
      pptApp.Quit
  
      Set pptSlide = Nothing
      Set pptPres = Nothing
      Set pptApp = Nothing
  
  End Sub
  </code></pre>
  
  <p>I get a Run-time error:</p>
  
  <blockquote>
    <p>Shapes (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here.</p>
  </blockquote>
  
  <p>At the line:</p>
  
  <pre><code>pptSlide.Shapes.PasteSpecial DataType:=ppPasteDefault, Link:=msoFalse
  </code></pre>
  
  <p><a href="http://im64.gulfup.com/pZNwxJ.png" rel="nofollow noreferrer">Error http://im64.gulfup.com/pZNwxJ.png</a></p>
  
  <p>I tried <code>pptSlide.Shapes.Paste</code> but it gives the same error.</p>
  
  <p>When I amend <code>pptApp.Presentations.Add(msoFalse)</code> to <code>pptApp.Presentations.Add</code> only it works but the PowerPoint App is displayed.</p>
  
  <p>When I change to <code>.PasteSpecial DataType:=ppPasteEnhancedMetafile</code> or <code>.PasteSpecial DataType:=ppPastePNG</code> everything runs smoothly even with <code>.Add(msoFalse)</code>.</p>
  
  <p>I am thinking it might be something to do with setting the focus or so.</p>