CreateDataSource Method

See Also         Example         Applies To

Creates a Word document that uses a table to store data for a mail merge. The new data source is attached to the specified document, which becomes a main document if it's not one already.

Syntax

expression.CreateDataSource(Name, PasswordDocument, WritePasswordDocument, HeaderRecord, MSQuery, SQLStatement, SQLStatement1, Connection, LinkToSource)

expression   Required. An expression that returns a MailMerge object.

Name   Optional Variant. The path and file name for the new data source.

PasswordDocument   Optional Variant. The password required to open the new data source.

WritePasswordDocument   Optional Variant. The password required to save changes to the data source.

HeaderRecord   Optional Variant. Field names for the header record. If this argument is omitted, the standard header record is used: "Title, FirstName, LastName, JobTitle, Company, Address1, Address2, City, State, PostalCode, Country, HomePhone, WorkPhone." To separate field names, use the list separator specified in Regional Settings in Control Panel.

MSQuery   Optional Variant. True to launch Microsoft Query, if it's installed. The FileName, PasswordDoc, and HeaderRecord arguments are ignored.

SQLStatement   Optional Variant. Defines query options for retrieving data.

SQLStatement1   Optional Variant. If the query string is longer than 255 characters, SQLStatement specifies the first portion of the string, and SQLStatement1 specifies the second portion.

Connection   Optional Variant. A range within which the query specified by SQLStatement will be performed. How you specify the range depends on how data is retrieved. For example:

LinkToSource   Optional Variant. True to perform the query specified by Connection and SQLStatement each time the main document is opened.