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

Free Support Forum - aspose.com

URGENT! Unlinking fields with Aspose.Words


My document contains multiple merge fields that reference Custom Document Properties in the document.

Using word automation one can call the function of “.Unlink();” which would take all the fields and replace them with the physical text of there result.

My merge fields look as follows


Example attached…

How can I unlink the files with Aspose?


Aspose.Words can update the values fo DOCPROPERTY fields using Document.Range.UpdateFields method. Total removal of this field substituting it with field result is not directly supported. It can be done by document node tree manipulation however. If you need to do it for some reason please state this reason here and I will try to compose the code that will do this for you.

Best regards,

We are going to need to do this for our project. Would you be able to give me the code for that? Thank you.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I think that the following code could be useful for you.

//Open document

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

//Set doc property value

doc.CustomDocumentProperties["SomeField"].Value = "my value";

//update fields in the document (DOCUMENTPROPERTY and DOCUMENTVALUE field will be updated)


//Get collection of FiledStart nodes

ArrayList propertyStarts = new ArrayList();

NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);

foreach (FieldStart start in starts)


if (start.FieldType == FieldType.FieldDocProperty)





//For each DOCUMENTPROPERTY Field Start

foreach (FieldStart start in propertyStarts)


Node currentNode = start;

Node fieldSeparator = null;

//Remove field code

while (currentNode.NodeType != NodeType.FieldSeparator)


currentNode = currentNode.NextSibling;



fieldSeparator = currentNode;

//Move to Field End

while (currentNode.NodeType != NodeType.FieldEnd)


currentNode = currentNode.NextSibling;


//Remove field separator


//Romove field end



//Save document


Best regards.