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

Jim DeMarco

"Pro Excel 2007 VBA"

Text
The first line activates the chart with an index of i. The second line retrieves the title of
the chart we just made active.
Next, we??™ll add a slide to place the chart on.
5. Add the following line of code:
Set m_oPptSlide = m_oPptShow.Slides.Add(i + 1, ppLayoutTitleOnly)
This line adds a new slide and gives it a layout that contains only a title placeholder.
6. Add the following code to the CreateChartSlides procedure:
With m_oPptSlide.Shapes.Placeholders(1)
sngChartStart = .top + .height
With .TextFrame.TextRange
.Text = sTitle
End With
End With
In this With...End With block, we are assigning a value to the sngChartStart variable,
which is the total of the title placeholder??™s Top and Height property values. This will be used
when we place the chart on the slide. Next, we add the chart title text to the title placeholder.
Next, we??™ll use the Excel Chart object??™s Copy method to place the chart in memory, and
then we can paste it into the slide and place it in its proper location.
7. Add the following code to the CreateChartSlides procedure:
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
CHAPTER 8 n OFFICE INTEGRATION 303
The completed CreateChartSlides subroutine should look like Listing 8-9.
Listing 8-9. Complete CreateChartSlides Subroutine
Sub CreateChartSlides()
Dim i As Integer
Dim sTitle As String
Dim sngChartStart As Single
Dim spacer As Integer
For i = 1 To 3
Worksheets(1).


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