Free Support Forum -

Bookmarks and Inserting Merge Fields

I think I found a bug. I have bookmarks around the mergefield. Then I run a Mailmerge. Then I want to take the merged document and find the bookmarks to insert mergefields again. I can't seem to get it to work. Does anyone have code to do this?


Thanks for your request. Please try using the following code:

Document doc = new Document("C:\\Temp\\in.docx");

doc.MailMerge.Execute(new string[] {"Test"}, new string[] {"Value"});

// Save output document.


Document doc2 = new Document("C:\\Temp\\out.docx");

DocumentBuilder builder = new DocumentBuilder(doc2);


// Insert MergeField

builder.InsertField("MERGEFIELD Test2");

// Save output document.


Please see the attached documents.

Best regards,