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

Jim DeMarco

"Pro Excel 2007 VBA"

Open the VBE by selecting the Developer ribbon ?¤ Code tab ?¤Visual Basic command,
or by pressing Alt+F11.
3. Add a new standard module in the Project Explorer.
Before we can begin accessing and working with the Word DOM, we need to add a reference
to Word in the References dialog box.
4. In the VBE, select Tools ?¤ References to display the References dialog box (shown in
Figure 8-2).
Figure 8-2. References dialog box
CHAPTER 8 n OFFICE INTEGRATION 288
5. In the References dialog box, scroll down until you see the Microsoft Word 12.0 Object
Library (shown in Figure 8-3).
Figure 8-3.Microsoft Word 12.0 Object Library selected
6. Select the Microsoft Word 12.0 Object Library.
7. Click OK.
8. Add the following module-level variables:
Private m_oWordApp As Word.Application
Private m_oWordDoc As Word.Document
These variables will hold the instance of our Word application and the new Word document
for the report.
9. Create a new subroutine named MakeWordDoc.
10. Add the following variable declarations:
Dim i As Integer
Dim sTitle As String
Dim sBody As String
These will contain a counter value used when we loop through our charts, and two string
values to hold the title and introductory text for the report. Next, we??™ll assign the title of our
report, ???2007 Sales Report,??? to the sTitle variable. Since we??™ll also be creating a PowerPoint
presentation from our VBA code, let??™s create some routines to provide that information to our
application.


Pages:
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271