Hi
Thanks for your request. You can try using the following code as a workaround:
// Create dummy datasource.
DataTable data = new DataTable();
data.Columns.Add(“item1”);
data.Columns.Add(“item2”);
data.Columns.Add(“item3”);
data.Columns.Add(“item4”);
data.Columns.Add(“item5”);
data.Columns.Add(“item6”);
data.Columns.Add(“item7”);
data.Columns.Add(“item8”);
data.Columns.Add(“item9”);
data.Columns.Add(“item10”);
// Add some dummy data.
for(int i =0; i<10; i++)
{
data.Rows.Add(new object[] { “item1”, “item2”, “item3”, “item4”, “item5”,
“item6”, “item7”, “item8”, “item9”, “item10” });
}
// Open template document.
Document doc = new Document(@“Test001\in.doc”);
// Execute mail merge.
doc.MailMerge.Execute(data);
// In this example we suppose that the original template has only one section.
// In this case, one section for each record will be created.
// So we can loop through all sections in the document and restart numberign of lists.
// We will use DocuemntVisitor to achieve this.
RestartNumberingHelper helper = new RestartNumberingHelper();
doc.Accept(helper);
// Save output document.
doc.Save(@“Test001\out.doc”);
=======================================================================
private class RestartNumberingHelper : DocumentVisitor
{
public override VisitorAction VisitSectionStart(Section section)
{
newList = null;
oldList = null;
return VisitorAction.Continue;
}
public override VisitorAction VisitParagraphStart(Paragraph paragraph)
{
// Check if the curren tparagraph is list item.
if(paragraph.IsListItem)
{
// If so we need to create a copy of the list and reset the list.
if (newList == null || (!paragraph.ListFormat.List.Equals(oldList) && newList != null))
{
oldList = paragraph.ListFormat.List;
newList = paragraph.Document.Lists.AddCopy(oldList);
}
paragraph.ListFormat.List = newList;
}
return VisitorAction.Continue;
}
private List oldList;
private List newList;
}
I also attached my test files.
Hope this helps.
Best regards.