|MailMergeExecuteWithRegions Method (DataSet)|
public void ExecuteWithRegions( DataSet dataSet )
Public Sub ExecuteWithRegions ( dataSet As DataSet )
public: void ExecuteWithRegions( DataSet^ dataSet )
member ExecuteWithRegions : dataSet : DataSet -> unit
Use this method to perform mail merge from one or more tables into repeatable mail merge regions in the document. The mail merge regions inside the document will dynamically grow to accommodate records in the corresponding tables.
Every table in the DataSet must have a name.
The document must have mail merge regions defined with names that refer to the tables in the DataSet.
To specify a mail merge region in the document you need to insert two mail merge fields to mark beginning and end of the mail merge region.
All document content that is included inside a mail merge region will be automatically repeated for every record in the DataTable.
To mark beginning of a mail merge region insert a MERGEFIELD with name TableStart:MyTable, where MyTable corresponds to one of the table names in your DataSet.
To mark the end of the mail merge region insert another MERGEFIELD with name TableEnd:MyTable.
To insert a MERGEFIELD in Word use Insert/Field command and select MergeField then type the name of the field.
The TableStart and TableEnd fields must be inside the same section in your document.
If used inside a table, TableStart and TableEnd must be inside the same row in the table.
Mail merge regions in a document should be well formed (there always needs to be a pair of matching TableStart and TableEnd merge fields with the same table name).