Free Support Forum - aspose.com

Eliminate merge fields

Hello:

I've loaded all the merge fields of a document in a drop down list using this

doc.MailMerge.GetFieldNames();

but the problem is it also includes table name like

«TableStart:Customer» «Phone»

«TableEnd:Customer »

I need to load the variable <> but it also loads <> and <>. How can I eliminate those?? Is there any way??

thanks-

Razin

Hi

Thank you for your inquiry. I think that you can try using the following code to solve this problem.

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

string[] fields = doc.MailMerge.GetFieldNames();

for (int i = 0; i < fields.Length; i++)

{

if (!fields[i].ToLower().Contains("tablestart") && !fields[i].ToLower().Contains("tableend"))

{

DropDownList1.Items.Add(fields[i]);

}

}

Please let me know if you would like to know something else.

Best regards.

Thank You

Razin