Free Support Forum - aspose.com

How to find section for a particular Merge Tag thru C#

Hi,

In a document there are multiple sections. In each section there are merge tags defined. How can I find the section for a particular merge tag through C# code?

Please let me know the solution for this asap.

Regards,
Sanjay Varma



Hi Sanjay,


Thanks for your inquiry. Sure, you can first move the cursor to the position where your MERGEFIELD is located in the document and then get the Section that is currently selected in this DocumentBuilder as follows:

Document doc = new
Document(@“C:\Temp\in.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToMergeField("your mergefield name");

Section sec = builder.CurrentSection;


I hope, this helps.

Best regards,

Hi Awais,

Thanks for your prompt reply.

Best Regards,
Sanjay

Hi Sanjay,


Please let us know any time you have any further queries. We are always glad to help you.

Best regards,