

Assembly WordDocument document = new WordDocument () document. Close () Īssembly assembly = typeof ( App ). ExecuteNestedGroup ( dataSet, commands ) //Saves and closes the Word document instance document. Add ( entry ) //Performs the mail merge operation with the dynamic collection document. Add ( entry ) //Retrieves the customer details entry = new DictionaryEntry ( "Orders", "CustomerID = %Customers.CustomerID%" ) commands. Add ( dataTable ) List commands = new List () //DictionaryEntry contain "Source table" (key) and "Command" (value) DictionaryEntry entry = new DictionaryEntry ( "Customers", string. Add ( dataTable ) dataTable = new MailMergeDataTable ( "Orders", GetOrders ()) dataSet. Opens the template document WordDocument document = new WordDocument ( "Template.docx" ) //Creates an instance of the MailMergeDataSet MailMergeDataSet dataSet = new MailMergeDataSet () //Creates the mail merge data table in order to perform mail merge MailMergeDataTable dataTable = new MailMergeDataTable ( "Customers", GetCustomers ()) dataSet.
Group objects in a word for mac document how to#
The following code example shows how to perform a nested Mail merge. You can use the “%TableName.ColumnName%” expression for getting the current value of specified column or field from the table.

You need to define commands with the table name and expression for linking the multiple data tables (explicit relation data) during nested Mail merge process. The MailMerge class provides various overloads for the ExecuteNestedGroup method to perform Mail merge for nested groups or regions in the Word document. In this template, Employees is the owner group and it has two child groups Customers and Orders. To execute nested mail merge, design your Word document template as follow. You can also predefine the group data that is populated to a merge field. Nested Mail merge operation automatically replaces the merge field with immediate group data. Create template for nested group mail merge You can perform nested Mail merge with relational or hierarchical data source and independent data tables in a template document.
