WordBasic Examples Using ODBC: MailMergeOpenDataSourceLast reviewed: July 30, 1997Article ID: Q110334 |
The information in this article applies to:
SUMMARYThis article contains an example that demonstrates the use of the following WordBasic statement or function:
MailMergeOpenDataSourceThis 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
SyntaxMailMergeOpenDataSource .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 MAINQ$ = 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 SubNote: 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=RedISAMThe 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 REFERENCESWord 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |