O'Reilly logo

Excel® VBA: 24-Hour Trainer by Tom Urtis

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

Chapter 30. Working with PowerPoint from Excel

With each new release of its Office suite, Microsoft has made it increasingly easier to share information between applications. Copying data from Excel, such as a worksheet range or chart, and pasting it into a PowerPoint slide is as simple as copying and pasting from Excel into a Word document.

Still, PowerPoint is a unique animal in that its primary purpose is not to manipulate data but to display images of data for presentation purposes. When you need to transfer data from Excel to PowerPoint, such as a chart or a range of cells, I recommend you use VBA's CopyPicture method, which will paste an image of the data — not the data itself — into PowerPoint.

CREATING A NEW POWERPOINT PRESENTATION

Creating a new PowerPoint presentation file is an uncomplicated process; all you do is follow the usual steps for creating the PowerPoint application and then add a presentation with the expression Presentations.Add. Here's an example from start to finish, ending up with a new presentation file and an initial slide:

Sub CreateNewPresentation()

'Declare Object variables for the PowerPoint application
'and for the PowerPoint presentation file.
Dim ppApp As Object, ppPres As Object
'Declare Object variable for a PowerPoint slide.
Dim ppSlide As Object

'Open PowerPoint
Set ppApp = CreateObject("PowerPoint.Application")
'Make the PowerPoint application visible.
ppApp.Visible = msoTrue
'Create a new Presentation and add a slide. Set ppPres = ppApp.Presentations.Add ...

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