Free Support Forum - aspose.com

Date field showing the format not the date

Hi.

I have a problem which I hope You can explain for me.

We have a simple system using Aspose.Words. In some of the documents we have date fields, and the idea is that the fields should be updated when the user has merged the document and opens it. Normally the field should merge into something like: 12.november 2007

On one of the test computers the field is however shown as:
{ TIME @ “d. MMMM yyyy” }
This is obviously the format of the time field. Why is this?

The problem only happens on one of the test computers, but not on the others (merging the same document of course). Can You help me?

Hi

Thanks for your inquiry. Unfortunately, Aspose.Words can update the results of DOCPROPERTY and DOCVARIABLE fields only. That’s why I would advise you to use MERGEFIELD instead TIME field. For example use the following field and the following code.

{ MERGEFIELD time \@ "d. MMMM yyyy" \* MERGEFORMAT }

Document doc = new Document(@"348_102103_jdh\in.doc");

string[] names = { "time" };

object[] values = { DateTime.Now };

doc.MailMerge.Execute(names, values);

doc.Save(@"348_102103_jdh\out.doc");

I hope that this will help you to solve your problem.

Have a nice day.