title: How to update embeded excel links in powerpoint 2010 using vba
body: <p>My problem is i have pasted my charts into <a href="/questions/tagged/powerpoint" class="post-tag" title="show questions tagged 'powerpoint'" rel="tag">powerpoint</a> and I am trying to update the embedded links via Excel-VBA. </p>
  
  <p>I have tried the codes below and failed:</p>
  
  <p><strong>code 1</strong></p>
  
  <pre><code>    AppPPT.Presentations.Open "D:\Demo.pptx", Untitled:=msoTrue
      AppPPT.ActivePresentation.UpdateLinks
      AppPPT.ActivePresentation.SaveAs "D:\Demo.pptx"
  </code></pre>
  
  <p><strong>code 2</strong></p>
  
  <pre><code>    For i = 1 To AppPPT.ActivePresentation.Slides.Count
      For s = 1 To AppPPT.ActivePresentation.Slides(i).Shapes.Count
          If AppPPT.ActivePresentation.Slides(i).Shapes(s).Type = msoLinkedOLEObject Then
              AppPPT.ActivePresentation.Slides(i).Shapes(s).LinkFormat.Update
          End If
      Next s
  Next i
  </code></pre>
  
  <p><strong>code 3</strong></p>
  
  <pre><code>    Set PPTTemplate = AppPPT.Presentations.Open("D:\Demo.pptx")
  
      ' update chart
      Dim osld As Slide
      Dim oshp As PowerPoint.Shape
  
      For Each osld In PPTTemplate.Slides
      For Each oshp In osld.Shapes
      With oshp
      If .HasChart Then
      .Chart.ChartData.Activate
      .Chart.ChartData.Workbook.Close
      .Chart.Refresh
      End If
      End With
      Next oshp
      Next osld
  
      AppPPT.Activate
  </code></pre>