Table of Contents

Method MergeToNewDocument

Namespace
DocWright.MailMerge
Assembly
DocWright.MailMerge.dll

MergeToNewDocument(WordDocument, IMergeDataReader, MailMergeOptions?)

Merges every record into a copy of the template, as Word's Edit Individual Documents does: one copy per record, each in its own section, every merge field replaced by its value, the main document's mail-merge settings (w:mailMerge) not carried. The template is not changed.

public static (WordDocument Document, MergeResult Result) MergeToNewDocument(this WordDocument template, IMergeDataReader data, MailMergeOptions? options = null)

Parameters

template WordDocument

The main document.

data IMergeDataReader

The records.

options MailMergeOptions

The options (their record separator is Word's section break here), or null for the defaults.

Returns

(WordDocument Document, MergeResult Result)

The merged document and what the merge did.

Exceptions

ArgumentNullException

template or data is null.

MergeTemplateException

A region marker is unbalanced or crossed.