SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 269 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


6. Add the following module-level variables:
Private m_oPptApp As PowerPoint.Application
Private m_oPptShow As PowerPoint.Presentation
Private m_oPptSlide As PowerPoint.Slide
The object types of these variables are plainly named. We have a variable to hold a reference
to the PowerPoint application, one for the Presentation object, and one to hold a Slide
object.
7. Add a new subroutine to the code module and name it MakePowerPointPresentation.
8. Add the following lines of code:
Set m_oPptApp = CreateObject("PowerPoint.Application")
Set m_oPptShow = m_oPptApp.Presentations.Add
In this code, we are instantiating an instance of the PowerPoint application using the
CreateObject function discussed in the previous example. Then we are adding a new presentation
to that instance.
Now that we have a presentation to work with, our next tasks are to create a title slide and
then add chart slides. In our Word example, we created helper functions to do this, and we will
do something similar here.
PowerPoint Helper Functions
Our next chore is to create a title slide. The title slide will consist of a title line plus descriptive
text, similar to the Word report we created in the last example.
1. Still working on the standard code module with your PowerPoint code, add a new subroutine
and name it CreateTitleSlide.
2. Add the following line of code:
Set m_oPptSlide = m_oPptShow.Slides.Add(1, ppLayoutTitle)
The PowerPoint Presentation object contains a Slides collection that naturally contains
all of the slides in a presentation file.


Pages:
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281