I have a base document with a number of mergefields. When I merge the data into the document to obtain a new document I mantain the fields in the document.
Thanks for the answer, but what I need is not exactly what you proposed.
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir
DocumentBuilder builder = new DocumentBuilder(doc);
//doc.UpdateFields(); // do not call this method before getting values
foreach (string fieldname in doc.MailMerge.GetFieldNames())
builder.MoveToMergeField(fieldname, false, false);
// The builder cursor should be positioned at the start of the field.
FieldStart fStart = (FieldStart)builder.CurrentNode;
Console.WriteLine(fieldname + " => " + fStart.GetField().Result);
//doc.UpdateFields(); // you may call this method after getting field values
Moreover, a field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end. Fields can be nested, contain rich content and span multiple paragraphs or sections in a document. The Field class is a "facade" object that provides properties and methods that allow to work with a field as a single object.