title: Edit PowerPoint datasheet chart object with Excel VBA
body: <p>I have a PowerPoint presentation that I need to update through Excel VBA and I am currently stuck at adding data to the datasheet within a chart. Below the code. What this should do is open the PowerPoint presentation through Excel VBA and assuming the Excel is open, take the range from there and paste it in the DataChart.</p>
  
  <p>I'm still fairly new to objects, more so to PowerPoint objects and I can't figure out how to paste it there. The object is a msoEmbeddedOLEObject and the OLEFormat.progID is "MSGraph.Chart.8" which I sadly do not understand.</p>
  
  <pre><code>Public sPath As String, sFile As String, sFilePPT As String
  
  Public PPApp As PowerPoint.Application
  Public PPPres As PowerPoint.Presentation
  Public PPSlide As PowerPoint.Slide
  Public PPShape As PowerPoint.Shape
  Public PPChart As PowerPoint.Chart
  Public PPChartData As PowerPoint.ChartData
  Public cTable As Excel.ListObject
  
  
  Sub OpenPPT()
  
  sPath = ThisWorkbook.Path &amp; "\"
  sFilePPT = "Presentation1.pptx"
  
  On Error Resume Next
  '==&gt; Check if PowerPoint is running
      Set PPApp = GetObject(, "PowerPoint.Application") 
      If PPApp Is Nothing Then
  '==&gt; If PowerPoint is not running, create new instance
          Set PPApp = CreateObject("PowerPoint.Application") 
  '==&gt; and make it visible (PowerPoint must be visible to be used)
          PPApp.Visible = True 
          Set PPPres = PPApp.Presentations.Open(sPath &amp; sFilePPT)
      End If
  On Error GoTo 0
  
  '==&gt; Reference presentation and slide
  On Error Resume Next 
  '==&gt; If there's at least one presentation, use it
      If PPApp.Windows.Count &gt; 0 Then 
          Set PPPres = PPApp.ActivePresentation
   '==&gt; use active slide
          Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex) 
      Else
          MsgBox "PowerPoint Presentation not found"
          Exit Sub
      End If
  On Error GoTo 0
  
  Set PPSlide = Nothing
  Set PPPres = Nothing
  Set PPApp = Nothing
  
  End Sub
  
  
  Sub test()
  
  Dim i As Byte
  Dim r As Range
  
  Call OpenPPT
  
  Set PPApp = GetObject(, "PowerPoint.Application")
  Set PPPres = PPApp.Presentations(1)
  Debug.Print PPPres.Name
  Set PPSlide = PPPres.Slides(2)
  PPSlide.Select
  Debug.Print PPSlide.Name
  Set PPShape = PPSlide.Shapes(2)
  PPShape.Select
  
  If PPShape.OLEFormat.progID = "MSGraph.Chart.8" Then 
      Set r = Workbooks("Budget_CM11.xlsm").Worksheets("Recap").Range("AQ12:AY17")
      r.Copy
  '==&gt; I see it opens the DataChart of the Chart for editing
      PPShape.OLEFormat.DoVerb 2 
  
  'code needed here that should copy the Excel range 
  'within the PowerPoint Object (Chart?) Data 
  
  End If
  
  
  
  End Sub
  </code></pre>