15.5. An Advanced Example—Creating a Graph in Access and Inserting It into PowerPoint

There aren't many applications for using VBA to send data from Access to PowerPoint. However, one application that's often requested but a little tricky to accomplish is exporting a graph from Access to PowerPoint. You could take advantage of the following example to update your presentation with the most current graph from your Access report.

This procedure is a bit complicated so we'll cover it in several steps. First of all, there's no easy method of copying a chart from within Access. Some developers have had success copying the actual MS Graph object, but we've found that method to be buggy at best and completely unreliable at worst. So, we've come up with another method that produces fairly accurate and reliable results. The first part of the procedure involves exporting the recordset you're interested in to an intermediate Excel file. You can easily use VBA code to create the graph within Excel. Once you have the graph created within Excel, you can reliably copy the graph object within Excel. The next step is to use VBA to create your PowerPoint presentation and add a slide. Once you've done that, you can paste the chart object into your slide and you get an instant updated presentation.

It's worth noting that you could also use VBA code to open an existing PowerPoint presentation, find a specific slide within the presentation, and place your graph there.

To perform these tasks, you'll ...

Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.