Replace Merge Fields with Text having Custom Formatting Styling during Mail Merge using C# .NET

Hello

I have a Merge Field in MS word that requires the following formatting

Example sentence:

“Use the Make Payment option on the Statements page to make a one-time debit transaction or set up pre-authorized payments.”

As you can see the “Make Payment” needs to be BOLD.

How can i do this?

@tony.woods.bell.ca,

I believe you can meet this requirement after reading the following section of documentation:

Please let us know if you may have any troubles and we will be glad to look into this further for you.

The examples are for excel file
I could not find for Word documents.

Do you have an example code?

@tony.woods.bell.ca,

One simply way is to just move the cursor to merge field and then start writing the formatted text. Sample code is as follows:

Document doc = new Document("C:\\Temp\\template.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToMergeField("a_MERGEFIELD");
builder.Write("Use the ");
builder.Font.Bold = true;
builder.Write("Make Payment");
builder.Font.Bold = false;
builder.Write(" option on the Statements page to make a one-time debit transaction or set up pre-authorized payments.");

doc.Save("C:\\temp\\20.9.docx"); 

Attachment: Test Template and Output Word Documents.zip (18.2 KB)