We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Showing box rather than newline in merge field


I have been a long time user of Aspose Words and have different versions running on our applications.

I have updated one of my apps to Aspose Words

I now have an issue in that when trying to populate a merge field that contains a newline, the following appears:

First line<>Second line

Rather than

First line
Second line

The VB code is as follows: str = “First line” & vbLf & “Second line”

This works as expected for older versions such as

Any assistance would be greatly appreciated


Thanks for your inquiry. We have tested the scenario with Aspose.Words for .NET 17.10 and unable to notice the reported issue. Please share your sample console application along with your template file as ZIP file here. We will look into it and will guide you accordingly.

Dim inputpath As String = ("input.docx")
Dim document As New Document(inputpath)
Dim firstline As String = "hello"
Dim secondline As String = "World"
Dim multiline As String = firstline & vbLf & secondline

document.MailMerge.Execute(New String() {"Name", "Name1"}, New Object() {multiline, "John snow"})


Thank you for your reply.

Based on what you have told me, I can now provide more information.

The problem is occurring when I am using IFieldMergingCallback.FieldMerging to change the color of the text.

The text needs to display as red, orange or green depending on flags set.

If I bypass setting the colour then it works as expected.

sample code is below:

If e.FieldName.Equals(“DiaHbaAch”) Then
'Here you can modify code according to your requirements.
run.Text = e.FieldValue
If bolDiaHbaAtTarget = True Then
font.Color = System.Drawing.Color.Green
End If
If bolDiaHbaNotAtTarget = True Then
font.Color = System.Drawing.Color.Red
End If
If bolDiaHbaNotAssessed = True Then
font.Color = System.Drawing.Color.Orange
End If
font.Size = 10.5
End If


Thanks for your feedback. As stated above please share a sample console project(without compilation error) along with the word template. It will help us to investigate and address your issue exactly.


Please find sample console project highlighting the problem.

'If you comment out the following line the vbLf will work
document.MailMerge.FieldMergingCallback = New HandleMergeField()

Sorry file attached App.zip (23.3 KB)
Input.zip (109.0 KB)


Thanks for sharing the sample project. I have tested the scenario and unable to notice the box instead of new line, but vbLf is not rendering as new line in both 17.10 and 14.4. You may use ControlChar.LineBreak, it gives expected results in both 17.10 and 14.4.

Dim multiline As String = firstline & ControlChar.LineBreak & secondline


Thank you for your response.

I can confirm that this has resolved the problem that I was having.

Thank you once again for your prompt responses and advice.