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

Free Support Forum - aspose.com

How to work with Fields?

I’m an absolute beginner and I’m trying to set the values of some fields in my document but I have no idea how to do.
The fields in Word looks like this: { DOCVARIABLE test.Testvalue* MERGEFORMAT }
Can anyone tell me what I have to do?


Thanks for your inquiry. If your document already contains document variable named “test.Testvalue” then you can set its value. For example see the following code:

//Open document
Document doc = new Document(@"Test098\in.doc");
//Set value of DocumentVariable
doc.Variables["test.Testvalue"] = "This is new value";
//Update fields in the document
//NOTE: Currently Aspose.Words updates DOCPROPERTY and DOCVARIABLE fields only
//Save output document

Also you can add document variable using the following code:

doc.Variables.Add(“test.Testvalue”, “test”);

Also see the following link

Hope this helps.

Best regards.

Thanks for Your quick reply.
It works fine.