WordBasic Examples Using ODBC: MailMergeOpenDataSource

Last reviewed: July 30, 1997
Article ID: Q110334
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c

SUMMARY

This article contains an example that demonstrates the use of the following WordBasic statement or function:

   MailMergeOpenDataSource

This article supplements the information in online Help. To open this Help topic, choose Contents from the Help menu and then choose Programming with Microsoft Word.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

MailMergeOpenDataSource

Syntax

MailMergeOpenDataSource .Name = text [, .ConfirmConversions = number] [, .ReadOnly = number] [, .LinkToSource = number] [, .AddToMru = number] [, .PasswordDoc = text] [, .PasswordDot = text] [, .Revert = number] [, .WritePasswordDoc = text] [, .WritePasswordDot = text] [, .Connection = text] [, .SQLStatement = text] [, .SQLStatement1 = text]

This macro connects to the Microsoft Access NWIND.MDB database, using the records in the Customers table as the data source for a Word 6.0 for Windows Mail Merge:

Sub MAIN
Q$ = Chr$(34) connect$ = "DSN=MS Access Databases;" connect$ = connect$ + "DBQ=c:\access\nwind.mdb;" connect$ = connect$ + "FIL=RedISAM;" MailMergeOpenDataSource .Name = "c:\access\nwind.mdb", .Connection = \ connect$, .SQLStatement = "SELECT * FROM Customers"
End Sub

Note: To determine the connection and query strings for MailMergeOpenDataSource, set query options manually, and then use MailMergeDataSource$() to return the strings.

The full ODBC connection string above is concatenated to produce:

   DSN=MS Access Databases;DBQ=c:\access\nwind.mdb;FIL=RedISAM

The connection string for the ODBC Microsoft Access driver uses the following keywords:

   Keyword     Description
   -------     -----------

   DSN         Name of the Microsoft Access data source
   UID         The user login ID
   PWD         The user-specified password
   DBQ         The Microsoft Access database
   FIL         File type (RedISAM)

To use a database that requires both a user login ID and a user-specified password, add the above keywords to the connection string. For example:

   DSN=MS Access Databases;UID=Smith;PWD=Sesame;DBQ=C:\ACCESS\NWIND.MDB;
   FIL=RedISAM

REFERENCES

Word Developer's Kit, p. 579. The Microsoft Access ODBC Help file, DRVACCSS.HLP, located in the Windows SYSTEM subdirectory.

Kbcategory: kbusage kbmacro KBSubcategory: kbmacroexample


Additional query words: 6.0 ODBC access winword 6.0a 6.0c word6
Keywords : kbmacroexample
Version : 6.0 6.0a 6.0c
Platform : WINDOWS


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.