Hi
I have a word template with 3 pages
1 and 3 are fixed
The 2 brings reserved words to replace and an image that must also be replaced
I need that page 2 to be duplicated n number of times (The number varies) and each time it is duplicated, replace the reserved words with different data and the same image
I’ve defined the “MyData” merge range that starts on top of the second page and ends on top of the third page and then I just execute the mail merge with some data.
The process will copy the merge range for each record in the data source and it will replace the MERGEFIELD elements with appropriate values from the data source.
var source = new
{
MyData = new[]
{
new { Num = 1, Place = "Place 1", View = "View 1", Tamano = "Tamano 1" },
new { Num = 2, Place = "Place 2", View = "View 2", Tamano = "Tamano 2" },
new { Num = 3, Place = "Place 3", View = "View 3", Tamano = "Tamano 3" },
new { Num = 4, Place = "Place 4", View = "View 4", Tamano = "Tamano 4" }
}
};
var document = DocumentModel.Load("Plantilla-with-MailMerge.docx");
document.MailMerge.Execute(source);
document.Save("Plantilla-with-MailMerge-Saved.docx");