We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get Fields in word Document

How can I do to get fieldvalues of a word document.
I have try some script but nothing it are correctly.

example script:
WordDocument document = new WordDocument(@"C:\Temp\Template.docx", FormatType.Docx);
WField Fields = new WField(document);

var Value  = Fields.FieldValue;

If I use this code the value of the FieldValue and "" but if I open the structural information of the document and navigate:
The list of Fields appears.

1 Reply

MR Manikandan Ravichandran Syncfusion Team January 31, 2020 06:18 PM UTC

Hi Francesco,

Thank you for contacting Syncfusion.

From the given details, we suspect that your requirement is get all the fields in the document and its field values. Based on this we have prepared the sample application which can be downloaded from the below link.

In this sample we have done the following things.
1. Load the template document.
2. Update the fields in the document in order to get field value.
2. Iterate each element in the word document
3. Find the fields alone in these elements
4. Add the fields along with the field values.
5. Close the document.

Note: Please find the input Word document in “wwwroot” folder of above sample location.

Please let us know if you have any other questions.

Manikandan Ravichandran

Live Chat Icon For mobile
Up arrow icon