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 274 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

The last few lines of this code close the PowerPoint application
and destroy all of the PowerPoint objects.
The completed MakePowerPointPresentation subroutine should look like Listing 8-11.
Listing 8-11. Complete MakePowerPointPresentation Subroutine
Sub MakePowerPointPresentation()
Set m_oPptApp = CreateObject("PowerPoint.Application")
Set m_oPptShow = m_oPptApp.Presentations.Add
CreateTitleSlide
CreateChartSlides
m_oPptApp.Visible = msoTrue
MsgBox "PowerPoint is open"
m_oPptApp.Quit
Set m_oPptSlide = Nothing
Set m_oPptShow = Nothing
Set m_oPptApp = Nothing
End Sub
CHAPTER 8 n OFFICE INTEGRATION 305
Running the Code
Now that we??™ve completed the coding, let??™s run it and see our results.
1. Place the insertion point anywhere inside the MakePowerPointPresentation subroutine.
2. Click the Run button on the VBE toolbar or press F5.
3. If the Excel window appears with the message box displayed, make PowerPoint the
active window.
The dynamically created PowerPoint presentation is displayed. It should look like
Figures 8-10 through 8-13.
Figure 8-10. Title slide
Figure 8-11. Baked Goods & Mixes slide
CHAPTER 8 n OFFICE INTEGRATION 306
Figure 8-12. Beverages slide
Figure 8-13. Candy slide
4. Return to the Excel window.
5. Click OK on the message box to finish running the code.
Very nice output, and not much more work than our Word document. If we want to
include the text description on our chart slides, we can do that as well. For that, we need to do
a few things differently, however.


Pages:
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286