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?

Hi

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
doc.Range.UpdateFields();
//Save output document
doc.Save(@"Test098\out.doc");

Also you can add document variable using the following code:

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

Also see the following link
https://docs.aspose.com/words/net/work-with-document-properties/

Hope this helps.

Best regards.

Thanks for Your quick reply.
It works fine.