Chapter 1: Automation with Other Office ProgramsIn This Chapter✓ Understanding Automation✓ Adding a contact to Microsoft Outlook✓ Merging data with a
674Merging Data with a Word DocumentFor this example, we created three bookmarks: CurrentDate, AccessAddress, and AccessSalutation. We then saved the
Book IXChapter 1Automation with Other Office Programs675Merging Data with a Word Document ‘Open Word using template and make Word visible Wrd.Docume
676Merging Data with a Word DocumentAfter opening an instance of Word, we set the location of the Word template created earlier. We use the Path prope
Book IXChapter 1Automation with Other Office Programs677Exporting Data to Excel Figure 1-7: The final merged document in Word. Exporting Data to Excel
678Exporting Data to Excel ‘Declare and set the Recordset object Dim rs As New ADODB.Recordset rs.ActiveConnection = cnn ‘Declare and set the SQ
Book IXChapter 1Automation with Other Office Programs679Exporting Data to Excel ‘Declare and set the Connection object Dim cnn As ADODB.Connection
680Exporting Data to Excel .Font.Bold = True .Font.Color = vbBlue End WithNow it’s time to take the data from the Recordset object and put it i
666Using Object Libraries Automation with other Microsoft Office programs works only when you have these programs installed on your computer. If you
Book IXChapter 1Automation with Other Office Programs667Using Object LibrariesExploring an object libraryAfter adding a reference to a program’s objec
668Using Object Librariesto VBA. For example, if VBA opens a Word document, everything in that Word document is also exposed. VBA can do anything in t
Book IXChapter 1Automation with Other Office Programs669Adding a Contact to OutlookIn the next few sections, you’ll see how Access can share informati
670Adding a Contact to Outlook ‘Set Contact Properties and Save With OlkContact .FirstName = Me.FirstName .LastName = Me.LastName Me.Email
Book IXChapter 1Automation with Other Office Programs671Adding a Contact to OutlookNow let’s look at the next block of code: ‘Set Contact Properties
672Merging Data with a Word Document Figure 1-4: The contact added to Outlook from VBA. Merging Data with a Word DocumentMicrosoft Word is probably th
Book IXChapter 1Automation with Other Office Programs673Merging Data with a Word Documentso you need to display them so you can see what you’re doing.
Commenti su questo manuale