We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can I get the literal name of MergeField which define in Microsoft Word?

Can I get the literal name of MergeField which define in Microsoft Word?
I add a MergeField in doc file which look like <>, when I press alt+F9, it changes to {MERGEFIELD test * MERGEFORMAT}.
Then I just edit this field literally like <test:ok>, and then press alt+F9, it shows {MERGEFIELD test * MERGEFORMAT}.
The charactors are different(<> <–> <test:ok>)<span style=“font-family: “Arial”,“sans-serif”;” lang=“EN-US”><o:p></o:p>, however, the codes are the same({MERGEFIELD test * MERGEFORMAT}).
And now, i want to get the field name, but the method MailMerge.getFieldNames() just return “test”, can I get “test:ok”?

Or can I get com.aspose.words.Field from com.aspose.words.Document before I do the method : com.aspose.words.MailMerge.executeWithRegions?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Each field in MS Word documents consists of FieldStart, FieldSeparator, FieldEnd nodes and nodes, which represents field code and field value. In general fields looks like the following:

[FieldStart]Field code[FieldSeparator]Field value[FieldValue]

What you see in the document is field value. If you press Alt+F9 you will see field code. If you need to get displayed text of a field, you should get text between FieldSeparator and FieldEnd. I think the code example provided in the following article could be useful for you:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-rename-merge-fields.html

Hope this helps.

Best regards.

Thanks a lot, alexey.
I am trying now, and I will give a feedback to you later.

HOHO~~~~
alexey, it works, I can get the literal name of MegreField.
I even don’t know how to thank you.
I will finish all the code and tell you the detail.