Free Support Forum -

Mailmerge features

Received : 2007/11/14 19:06:15
Message : Hello,

I am wondering if the following are possible in Aspose words?

When performing mail merges I need to do the following:

I have an optional field that needs the following formatting:
"Heading - the remaining text......" I need the heading to be in Bold and the remainder of the paragraph to be normal text. If there is no text for this heading, then it should not appear at all.

Changing the color of the font based on the data:
I would like to following to appear in a single merge field depending on the response

Good(green) or Bad(red) or Borderline(orange). Is it possible to change the color of the mergefield text in the VB code behind?

Finally, I have two rows in the middle of a table that I do not want to appear if some conditions are not met. Is there any way to only include these two rows if the conditions are met?

This message was posted using Aspose.Live 2 Forum


Thanks for your interest in Aspose products. I think that you can try to use MergeField event to achieve this. For example see the following code.

Sub Main()

Dim doc As Document = New Document("in.doc")

AddHandler doc.MailMerge.MergeField, AddressOf HandleMerge

Dim names As String() = {"Field1"}

Dim values As String() = {"Bold text |Red text |Regular text"}

' Execute mail merge.

doc.MailMerge.Execute(names, values)


End Sub

Private Sub HandleMerge(ByVal sender As Object, ByVal e As MergeFieldEventArgs)

If e.FieldName = "Field1" Then

Dim builder As DocumentBuilder = New DocumentBuilder(e.Document)


Dim arr As String() = e.FieldValue.ToString().Split("|")

Dim i As Integer = 0

For i = 0 To arr.Length - 1

If i = 0 Then


builder.Font.Bold = True



ElseIf i = 1 Then


builder.Font.Color = System.Drawing.Color.Red








End If


End If

End Sub

Also see the following links.

I hope that this will help you.

Best regards.