ChartObjects(i).Activate
sTitle = ActiveChart.ChartTitle.Text
Set m_oPptSlide = m_oPptShow.Slides.Add(i + 1, ppLayoutTitleOnly)
With m_oPptSlide.Shapes.Placeholders(1)
sngChartStart = .top + .height
With .TextFrame.TextRange
.Text = sTitle
End With
End With
Worksheets(1).ChartObjects(i).Copy
spacer = 20
With m_oPptSlide.Shapes.Paste
.top = sngChartStart + spacer
.height = m_oPptSlide.Master.height - sngChartStart + spacer
.left = m_oPptSlide.Master.width / 2 - .width / 2
End With
Next i
End Sub
Completing the MakePowerPointPresentation Procedure
Moving our attention back to the MakePowerPointPresentation subroutine, we will now insert
our helper functions into the procedure and view our results. We will also add some cleanup
code.
CHAPTER 8 n OFFICE INTEGRATION 304
1. In the MakePowerPointPresentation subroutine, move the insertion point to a blank
line after the two lines of code previously entered (shown in Listing 8-10 for reference).
Listing 8-10.MakePowerPointPresentation Subroutine So Far
Sub MakePowerPointPresentation()
Set m_oPptApp = CreateObject("PowerPoint.Application")
Set m_oPptShow = m_oPptApp.Presentations.Add
End Sub
2. Add the following two lines of code calling the helper functions:
CreateTitleSlide
CreateChartSlides
3. Add the following code to display the results of your work and to perform the necessary
cleanup operations:
m_oPptApp.Visible = msoTrue
MsgBox "PowerPoint is open"
m_oPptApp.Quit
Set m_oPptSlide = Nothing
Set m_oPptShow = Nothing
Set m_oPptApp = Nothing
We are making our m_PptApp object visible and freezing the code with a message box, as
we did in our Word example.
Pages:
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285