title: PowerPoint VBA - Update linked graph from Excel at regular intervals
body: <p>I'm trying to build this system where I have this PowerPoint presentation with a linked graph from an external Excel file. I've seen that I can right click this graph in PowerPoint and click "Update link" and the graph is automatically updated. </p>
  
  <p>But what if I want this automated? If this can be done without creating an Add-in that would have been great. So which event handlers are there in PowerPoint? I reckon there's an event for SlideChanged or something? Could I possibly have the presentation go in an endless loop and update the link at each new slide switch? There are possibly huge amounts of graphs. And one slide for each section of graphs. </p>
  
  <p>Or, any other bright ideas?
  The system I'm trying to build is basically a framework for collecting data and displaying it in whatever form that might be wanted. Data is automatically imported from an economy software and into a database. So I've created a command line application that basically opens an Excel file and runs a macro (collecting the fresh data and copy it into the worksheet). This command line application is set to run as specific times via Scheduled Tasks. And it's this data that I want to show graphs from, automatically. </p>
  
  <p>I actually did a large bit of it myself :)</p>
  
  <p>Here's the code for VB.NET application (Can be used as command line application)</p>
  
  <pre><code>Imports Microsoft.Office.Interop
  Public Class Form1
  
      Dim oPPTApp
  
      Sub updatePPTGraph()    
          For Each oSlide In oPPTApp.ActivePresentation.Slides
              For Each oShape In oSlide.shapes    
                  If oShape.Type = 10 Then
                      oShape.LinkFormat.Update()
                  End If
  
              Next
          Next
      End Sub
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          oPPTApp = New PowerPoint.Application
          oPPTApp.visible = True
          Dim oPresentation As PowerPoint.Presentation
  
          oPresentation = oPPTApp.Presentations.Open("C:\Users\kenny\Documents\Charttest.pptx")
          updatePPTGraph()
      End Sub
  End Class
  </code></pre>
  
  <p>This is clearly a start. I need to figure out if it can be done while a slideshow is showing as well. But I think it should be possible. Will update when I manage to get something worth mentioning :)</p>