WordBasic Examples Using ODBC: MailMergeOpenDataSource |
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.
Additional query words: 6.0 ODBC access winword word6
Keywords : kbmacroexample kbofficeprog
Issue type :
Technology :
Last Reviewed: March 28, 2000 |