Free Support Forum -

Detecting Merge Field formats


Is there a way to retreive the format on a merge field? Some of my word documents have \@ "dd-MMM-yyyy" or \# "$#,##0.00". I'd liked to be able to retreive this information when I get the field names from the document (ie document.MailMerge.GetFieldNames()). So something like "document.MailMerge.GetFieldFormats()" which either gets an array of strings with either the format or "" if there isn't any.

I'm not sure if this can already be done, but I sure can't find it if it can.


Hi Patrick,

Thank you for your interest in Aspose.Word.

At the moment Aspose.Word does not provide a built-in method like the mentioned one, but you could implement a simple fragment of code like this:

NodeList fieldStarts = doc.SelectNodes("//FieldStart");

foreach (FieldStart fieldStart in fieldStarts)


if (fieldStart.FieldType == FieldType.FieldMergeField)


Run fieldCode = (Run)fieldStart.NextSibling;

// Run.Text contains field code that includes format, e.g. " MERGEFIELD MergeField1 \@ "dd-MMM-yyyy" \* MERGEFORMAT "



That’s all i need to know, thanks a lot.