How to Link a Microsoft Access Table in a Word Document

Last reviewed: July 30, 1997
Article ID: Q100932
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c
  • Microsoft Access versions 1.0, 1.1

SUMMARY

This article describes how to create a link in Microsoft Word for Windows to a Microsoft Access table. You can link a Microsoft Access table or query to your Word document, but you cannot link a Microsoft Access form or report.

MORE INFORMATION

Microsoft Access copies a table to the Windows Clipboard in unformatted text format, so when you link a Microsoft Access table to your Word document, it appears in tab-delimited text format.

You cannot update an automatic link to a Microsoft Access table. After you create an automatic link, you must change it to manual using the Links command from the Edit menu. Then you can use the Links Update command (from the Edit menu) or press F9 to update the Access information. For more information on editing and updating links, see pages 686-690 in the Word for Windows "User's Guide."

Due to a limitation in Microsoft Access, you can only link an entire Microsoft Access table in a client application. As a result, you cannot link a portion of a Microsoft Access table to your Word document. If you copy part of the Microsoft Access table to link to your Word document, the Paste Link button is unavailable, and the Source is Unknown in the Paste Special dialog box in Word.

Creating the Link

  1. In Microsoft Access, activate the Database window.

  2. Choose the Table button.

  3. Select the icon representing the desired table to copy. From the Edit menu, choose Copy. (Note: Do not open the table and choose Select All Records from the Edit menu.)

  4. Switch to Word for Windows.

  5. From the Edit menu, choose Paste Special.

  6. In the Data Type box, select Unformatted Text and then choose the Paste Link button.

         NOTE: Unformatted Text is the only selection that appears in the
         Data Type box.
    

The above steps create a DDEAUTO field in the document that can be displayed by turning on Field Codes from the View menu. The DDEAUTO field will appear as follows:

   {DDEAUTO MSAccess "database.mdb;Table tablename" All \* mergeformat \t}

To change the link to manual so that it will update correctly, choose Links from the Edit menu, select the desired link, and choose Manual under Update. This will change the DDEAUTO field to a DDE field that can be manually updated by pressing the F9 key.

This field can also be created manually by typing in the above field code (press CTRL+F9 to create the field brackets) and pressing F9 to update the field and establish the link. The database must be open to successfully create and update the link.

The DDE field linking a Microsoft Access table can also be edited to specify different items in the table. "All" is the item requested by default when copying and pasting the table in the above example. However, the following items can be used in the place of "All" in the DDEAUTO field code to link different items in the table:

   Item          Result
   -------------------------------------------------------------------

   All           All the data in the table including the column names.

   Data          All rows of data without the column names.

   FieldNames    A list of Columns.

   NextRow       Only the next row in the table/query. When the
                 conversation is first started, NextRow returns the
                 first row. If the current row is the last record and
                 NextRow is executed, the request will fail.

   PrevRow       Only the previous row. If PrevRow is the first
                 request ever a new channel the last row of the
                 table/query is returned. If the current row is the
                 first record the request for PrevRow will fail.

   FirstRow      Data in the first row of the table/query.

   LastRow       Data in the last row of the table/query.

   FieldCount    Count of columns in the table/query.

   MacroName     You can also send the name of a macro to be executed.

For example, the following field creates a link to the field names in the Employees table in the sample database NWIND.MDB:

   {DDE MSAccess "C:\\ACCESS\\NWIND.MDB;Table Employees" FieldNames
     \* mergeformat \t}

For more information on linking from a Microsoft Access database to a Word for Windows document, query on the following words in the Microsoft Knowledgebase:

   msaccess and ddeauto

Reference(s):

Word for Windows "User's Guide," version 2.0, pages 686-690


KBCategory: kbole kbusage kbhowto
KBSubcategory: kbtable
Additional query words: 2.0 2.0a 2.0a-CD 2.0b 2.0c ole range
winword2 winword area
Version : 2.0 2.0a 2.0a-CD 2.0b 2.0c


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.