We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Repeat 2 table rows using MailMerge.ExecuteWithRegions

My word template contains this table:
Frequent Flyer Information

Recorded Value New Value
(leave blank if recorded value is correct)
«TableStart:FF»Airline / Program «FrequentFlyerDesc»
Membership Number «FrequentFlyerNumber» «TableEnd:FF»

But when running ExecuteWithRegions I get this error:
Mail merge region ‘FF’ is badly formed. TableStart and TableEnd should be in the same section, same table row or same table cell.
Basically I want to repeat these two table rows for each dataitem. How can I do it?

Thanks for your request. I think that you can achieve this using the following template. (Also see the attached documents)

Recorded Value New Value
(leave blank if recorded value is correct)


Airline / Program «FrequentFlyerDesc»
Membership Number «FrequentFlyerNumber»

Here is code example for you.

public void Test110()
    // Prepare data
    DataTable table = new DataTable("FF");
    for (int i = 0; i < 10; i++)
        DataRow row = table.NewRow();
        row["FrequentFlyerDesc"] = "test_" + i.ToString();
        row["FrequentFlyerNumber"] = "test_" + i.ToString();
    // open template
    Document doc = new Document(@"Test110\in.doc");
    // Add MergeField event handler
    doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField110);
    // Execute mail merge
    // Save output document
void MailMerge_MergeField110(object sender, MergeFieldEventArgs e)
    if (e.FieldName == "FrequentFlyerNumber")
        // Get parent Table
        Table myTable = (e.Field.Start.ParentParagraph.ParentNode.ParentNode.ParentNode as Table);
        // Remove empty peragraph after table
        // Remove empty paragraphbefor table

I hope this could help you.
Best regards.