Change value or insert merge field


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

I’ve downloaded the trial version of Aspose.Word 2.1.1. Can you please show me how to set a value to a merge field without deleting it.

Or, if we cannot, how to insert a new merge field.

We tried with DocumentBuilder.MoveToMergeField and then DocumentBuilder.Write methods but the DocumentBuilder.MoveToMergeField removes the merge field.

We tried to insert the merge field using DocumentBuilder.InsertField but it fails.

I need this information as soon as possible


We think setting value of a merge field without deleting the field is not a good idea. Why? Because if you do that and then update the fields in MS Word, the value will always be reset back to <>. So I suggest you reconsider your course of action, maybe use bookmarks instead.

If you want to insert a merge field programmatically, it is very easy:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField(@" MERGEFIELD MyFieldName \* MERGEFORMAT", "");