Split mailmerge into multiple (word) documents

hi,

is there a way to split a mailmerge document into multiple word documents? I tried to extend your NestedMailMerge sample with some code I found in another request but it produces just one document for the two orders:

.
.
.

// Save the output to file
doc.Save(dataDir + "Invoice Out.doc");
int index = 0;
foreach(Section sect in doc.Sections)
{
    //Create new document
    var dst = new Document();
    // Remove all sections
    dst.FirstSection.Remove();
    // Import section from the source document
    dst.Sections.Add(dst.ImportNode(sect, true, ImportFormatMode.KeepSourceFormatting));
    // Save doucument
    dst.Save(dataDir + string.Format("out_{0}.docx", index), SaveFormat.Docx);
    index++;
}

Thanks
Wolfgang Raab

Hi Wolfgang,
Thanks for your request. I think you should use the same technique as described here to achieve what you need:
How to Produce Multiple Documents during Mail Merge
Hope this helps.
Best regards,

I’ve found a solution but I had to create a new DataSet for each order because MailMerge.Execute would not fill the (Item-) table.

Just one more question. Is it possible to perform a MailMerge on a template as the one I’ve attached? It contains of simple MergeFields and a Table (MERGEFIELD TableStart:Order was removed).

Thanks
Wolfgang Raab

Hi Wolfgang,
Thanks for your inquiry.
Just incase, if you are looking to produce multiple documents when using nested mail merge then you can use the code found in this thread to achieve this.
If this is indeed what you are looking for you may save some time using this method instead of recreating your data sources.
Thanks,

Thanks now everything works.

Hi there. All the links solving this issue are dead. Would it be possible to have this question answered again or some working links?

Thanks
Dylan Reeder

@dreeder,

Please refer to the following section of documentation:
How to Produce Multiple Documents during Mail Merge

The other thread link is:
https://forum.aspose.com/t/create-new-document-for-each-nested-region/74108