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

Free Support Forum - aspose.com

Can I access merge field formatting rules from code?

Hi,


I want get access to the extra mergefield information that users might add to document templates. For example, they might specify the “data to be inserted before the merge field”…

Is it possible when I process the document and apply the mail merge that I can get access to this extra information at all?

Thanks


Hi

Thanks for your request. Merge field formatting is applied using formatting switches. Unfortunately, there is no direct way to access them upon executing mail merge. The only way to access them is getting and parsing field code. Field code is the text between FieldStart and FieldEnd nodes of the appropriate field. You can see field codes in MS Word by pressing Alt+F9.

Best regards,

Hi


The field code that I have looks like this:

<span style=“font-size:11.0pt;line-height:
115%;font-family:“Calibri”,“sans-serif”;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:
minor-latin;mso-bidi-font-family:“Times New Roman”;mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>{MERGEFIELD CourseDate.EndDate @ “dd-MMM-yyyy h:mm am/pm”}
<span style=“font-size:11.0pt;line-height:
115%;font-family:“Calibri”,“sans-serif”;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:
minor-latin;mso-bidi-font-family:“Times New Roman”;mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>
Can I get at this raw data and parse this?

Hi

Thanks for your request. Yes, you can, but there is no direct way. You can use the same approach as used here:

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

Best regards,