Free Support Forum - aspose.com

Get elements between two Merge fields?

Hi,
Yes merge field can be used to replace a field with a value.
But if when I want to delete everything between two merge fields, how can I implement it?
First I think about creating a range between those merge fields, but I could not find any way to do it.
Can you give me a suggestion?
Thanks

Hi

Thanks for your inquiry. I think that you can try using sections in your template. For example see attached document and the following code.

//Open that template document

Document doc = new Document("in.doc");

//Remove section

doc.Sections[1].Remove();

string[] names = { "FirstName", "LastName", "Company" };

string[] values = { "Alexey", "Noskov", "Aspose" };

//Execute mail merge

doc.MailMerge.Execute(names, values);

//Save output document

doc.Save("out.doc");

I hope this could help you.

Best regards.