Free Support Forum - aspose.com

Formatted fields

I have a document template(attached - Basic Letter.doc) from which I am creating a document. In the template, the DOS field has a switch to display the format as January 1, 2010 - {DOCPROPERTY "~DOS" \@ "MMMM d, YYYY" }.

Using Aspose, I pass the values into the custom document properties & then update the fields:

  • doc.CustomDocumentProperties["~PtFirst"].Value = firstname;
  • doc.CustomDocumentProperties["~PtMiddle"].Value = middlename;
  • doc.CustomDocumentProperties["~PtLast"].Value = lastname;
  • doc.CustomDocumentProperties["~DOS"].Value = dateofService;
  • doc.Range.UpdateFields();

However, in the final saved document(saved.doc), the formatting is not put in. The date instead displays as 01/01/2010.

What can be done about this?

Hello

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

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (8.1.0). You can download this version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

I use the following code for testing:

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

doc.CustomDocumentProperties["~DOS"].Value = DateTime.Now;

doc.UpdateFields();

doc.Save("out.doc");

Best regards,