Inserting Fields with mergeField events

I have a requirement to insert a word or excel LINK field when I meet a merge field that looks like the following "Excel:FieldName" or "Word:FieldName". I want to use mergefields events but Iam unsure how I would use the document builder to achieve this. As I would need to have these fields in a mergeRegion also.

I think I would need to use moveToMergeField then insertField to insert the Link. The problem is iam unsure how moveToMergefield will behave in a merge field situation where there may be fields with similar names? Also if I attach a mergeField Event handler iam assuming it will fire every time a mergefield is encountered, does this mean I will have to handle everysingle merge field, or if I dont choose to do anything about it will it just insert the text as normal?

Thanks again Michael

Hi Michael,

Thank you for considering Aspose.

1) You have chosen the right approach.

2) If the template contains some merge fields with similar names, DocumentBuilder.MoveToMergeField will simply move to the first of them.

3) If you do nothing about the merge field inside the merge handler, the engine will insert the text as normal.

Thanks, Thats sounds like exactly what I need, I just have one more concern which is merge regions. If I use a merge region to repeat a document section then there will not be multiple merge fields with the same name until after this has finished, so will the event fire as the region repeats, or will it move to bookmark after the region has repeated?

The event is fired as the region repeats and the engine is going to fill the merge field with data from the next data record. I’m not sure what bookmark you mean.