Sometimes you may need to perform "manual" mail merge using DocumentBuilder or fill a merge field in a special way inside a mail merge event handler. That is when MoveToMergeField could be useful. The method accepts the name of the merge field. It moves the cursor to a position just beyond the specified merge field and removes the merge field.
Example DocumentBuilderMoveToMergeField
Shows how to move the cursor to a position just beyond the specified merge field.
[C#]
Document doc = new Document(MyDir + "DocumentBuilder.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("NiceMergeField");
builder.Writeln("This is a very nice merge field.");
[Visual Basic]
Dim doc As Document = New Document(MyDir & "DocumentBuilder.doc")
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
builder.MoveToMergeField("NiceMergeField")
builder.Writeln("This is a very nice merge field.")
[Java]
Document doc = new Document(getMyDir() + "DocumentBuilder.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToMergeField("NiceMergeField");
builder.writeln("This is a very nice merge field.");
Note that moving the cursor to a merge field deletes the merge field from the document.
The comparison is not case-sensitive.