O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required