Microsoft Office Automation Word

How to Use Automation to perform the merge from Access to Word 97  August 29, 2013 – 00:25
Services - Training

Advanced: Requires expert coding, interoperability, and multiuser skills. This article shows you how to use Automation to run a Microsoft Word 97 for Windows mail merge in Microsoft Access version 7.0 or 97.

For information about how to perform a mail merge in Word 7.0 Microsoft Access 7.0, please see the following article in the Microsoft Knowledge Base:

154571 (

Word 97 uses Visual Basic for Applications object hierarchy used in other Microsoft Office applications. Word 7.0 and earlier uses a simple model called WordBasic command. By using Automation, you can perform a mail merge in a Microsoft Word 97 to Microsoft Access. The example in this article uses the methods of object's Execute OpenDataSource and MailMerge in Word 97.

Example: Joining a Microsoft Access Query with a Word 97 document

  1. Start Microsoft Access and open a database or create a new one.
  2. Create a module and type the following procedure:

    Function MergeIt () As Word.Document Dim objWord September objWord = GetObject ("C: \ MyMerge.doc", "Word.Document") 'Make Word visible. objWord.Application.Visible = True 'Set the mail merge data source as the Northwind database. objWord.MailMerge.OpenDataSource _ Name: = "C: \ Program Files \ Microsoft" & _ "Office \ Office \ Samples \ Northwind.mdb", _ LinkToSource: = True, _ Connection: = "TABLE Customers", _ SQLStatement: = "Select * from [Customers]" 'Execute the mail merge. objWord.MailMerge.Execute End Function

    Note: If you want to print the merged document, delete the previous EXECUTE statement and add the following four lines of code above the End Function statement:

    objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute 'The Following line must follow the Execute statement Because The 'PrintBackground property is available only When a document window is 'Active. Without this line of code, the function will end before Word 'Can print the merged document. objWord.Application.Options.PrintBackground = False objWord.Application.ActiveDocument.PrintOut

  3. The module is still open in Design view, click References on the Tools menu. Add to the list of available references to the object library Word 97. If the object library is not listed, click the Browse button and locate the file Msword8.olb.
  4. To test this function, type the following line in the Debug window, and then press ENTER:

    ? MergeIt ()

    An instance of Word 97 is opened, displays MyMerge.doc and then are combined with the Customers table in the sample database Northwind.mdb.

, oppure avviare l'Assistente di Microsoft Access 97. For more information about Automation, search the Help Index for automation, or ask the Microsoft Access 97 Office Assistant. o chiedere l'Assistente di Microsoft Access 97. For information about using Microsoft Access Object Browser to explore the methods and properties of Microsoft Word 97 Visual Basic objects of applications, search the Help Index for automation, using the Object Browser or ask the Microsoft Access 97 Office Assistant .

Article ID: 159328 - Last Review: January 19, 2007 - Revision: 3.3

  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
  • Microsoft Word 97 Standard Edition


You might also like:

Word 2008 Quick Letterhead
Word 2008 Quick Letterhead

Office Automation

Is just what it sounds. Those things which AUTOMATE jobs in the office. Your resume should show this using action verbs and show a history, wihtout being vague....
Produced reports for yearly meetings of employees at Annual Convention.
Utilized Microsoft Word to write documents for daily correspondence, memos and blah blah blah.
Proficient in LexisNexis as required to research case histories for reports.
Hope this helps.

A novice's guide to backing up a PC  — ITProPortal
There's also an Outlook 2007/2003/2002 add-in from Microsoft called Personal Folders Backup that does just what it says. Follow these instructions from ..

Related posts:

  1. Microsoft Office Automation tutorial
  2. Microsoft Office Automation download
  3. Microsoft Office