Application")
Set m_oWordDoc = m_oWordApp.Documents.Add
sTitle = GetTitle
sBody = GetTitleBody
CHAPTER 8 n OFFICE INTEGRATION 296
With m_oWordApp
.Selection.Style = .ActiveDocument.Styles("Heading 1")
.Selection.TypeText sTitle
.Selection.TypeParagraph
.Selection.TypeText sBody
For i = 1 To 3
.Selection.TypeParagraph
InsertText i
InsertChart i
Next i
End With
m_oWordApp.Visible = True
MsgBox "word s/b open now"
m_oWordApp.Quit
Set m_oWordApp = Nothing
End Sub
Now let??™s run the code and see the finished product.
6. Place the insertion point anywhere inside the MakeWordDoc subroutine.
7. Click the Run button on the VBE toolbar or press F5.
The completed report will appear, and should look similar to Figure 8-6.
Figure 8-6. The completed summary report displayed in Print Preview mode
CHAPTER 8 n OFFICE INTEGRATION 297
The Word DOM is very rich and contains many other useful objects for you to code
against. Once you??™ve added a reference to Word in the VBE, you can explore its many features
in the Object Browser (which you can access by pressing F2). Figure 8-7 shows a view of the
Word objects as displayed in the Object Browser.
Figure 8-7.Word objects displayed in the Object Browser
8. Return to the Excel window.
9. Click OK on the message box and let the code run its cleanup.
Now that we??™ve got our report completed in Microsoft Word, let??™s look at PowerPoint and
create a presentation based on this data.
Creating a PowerPoint Presentation
Now that you??™ve had a little experience in navigating Word??™s DOM, you should be comfortable
enough to dive into the PowerPoint DOM.
Pages:
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279