PowerPoint VBA - regularly update linked chart from Excel

I am trying to create this system where I have a PowerPoint presentation with a linked graph from an external Excel file. I saw that I can right-click this graph in PowerPoint and click "Refresh Link", and the graph will automatically update.

But what if I want this to be automated? If this can be done without creating an add-in, that would be great. So what event handlers are there in PowerPoint? I believe an event for SlideChanged or something else? Can I present the presentation in an endless loop and update the link on each new slide switch? There are perhaps a huge number of graphs. And one slide for each section of the graphs.

Or any other bright ideas? The system I'm trying to build is basically a structure for collecting data and displaying it in any form that may be requested. Data is automatically imported from software for the economy and into the database. Therefore, I created a command line application that basically opens an Excel file and runs a macro (collects fresh data and copies it to a worksheet). This command line application launches at a specific time through scheduled tasks. And this is the data that I want to show graphs from automatically.

Actually I did it myself :)

Here's the code for the VB.NET application (can be used as a command line application)

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

. , , -. , . , -, :)

+3
1

(.. Excel) ; , , , .

, PPT Excel, ... , PPT.

0

All Articles