8. Add the following line of code after the With...End With block we just added:
Worksheets(1).ChartObjects(i).Copy
This line of code copies the current Chart object onto the Windows clipboard for later
pasting into our PowerPoint slide template.
CHAPTER 8 n OFFICE INTEGRATION 309
So we??™ve got our text elements in place and our chart sitting in memory waiting to be
dropped into our slide template. However, we can??™t just paste our chart into the third placeholder
area on our template as we could with the text-based Placeholder objects. To place the
chart, we have to get the coordinates of the third placeholder (top, left, height, and width).
Then we remove the Placeholder object and paste in the chart, placing it accordingly.
9. Add the following lines of code after the Copy command you just added:
Set oShape = m_oPptSlide.Shapes(3)
With oShape
top = .Top
left = .Left
width = .Width
height = .Height
.Delete
End With
Here, we are setting oShape to hold the third shape, which is the chart placeholder. Then
we are storing its dimensions and location in our top, left, width, and height variables. Once
we have that information, we are deleting the Shape object using its Delete method.
10. Immediately after this code, add the following code:
With m_oPptSlide.Shapes.Paste
.Top = top
.Left = left
.Width = width
End With
This code, which places and sizes the chart, is similar in function to our previous example.
We are placing it in the exact location of the placeholder we just removed.
Pages:
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289