Free Support Forum -

Mail Merge Problem Using a Multiline TextBox

I am doing a mail merge using data that was created from a multiline textbox.

The word document ends up putting junk square type characters in, instead of the carriage return and line feed.

Reading some of the other topics I understand this is due to word not being able to understand what vbcrlf is, but I cannot find a solution to this problem.

I have tried a manual replace function on the column in the datatable to replace vbcr and vblf, which is working, but I don’t know what to replace it for so that word will understand it. I have also tried replacing it to chr(13) and the junk character still appears.

On another topic I was that putting a carriage return after the merge field in word may work, but I cannot find how to do this either.

Is there any solution to my problem?


In general, Aspose.Word takes care and recognizes vbCrLf, vbLf and vbCr characters and converts them all to char(13) - this is a paragraph mark in a Word document.

Make sure you are using latest version of Aspose.Word. Let me know if that still does not work, send your document to

Sorry, I don’t fully understand your second question. What do you want to achieve?

Sorry, there wasn’t a second question, think I just typed it wrong and it sounded like a question :slight_smile:

Word doesnt seem to recognise the carriage returns, its just putting in the junk character.

I am just about to send you the template I am using, and also the document that is created after the mail merge so you can see what I mean.


It all works correctly, we even had a unit test for it. Just make sure you are using the latest version of Aspose.Word. Let me know if you still have the problem.


/// The data field can contain paragraph marks, so mail merge must create multiple paragraphs.

public void TestMailMergeWithCr()

Document doc = TestUtil.Open(@“TestMailMergeWithCr.doc”);
//2 for cells, 1 for row and 1 for end of section.
Assertion.AssertEquals(4, doc.Model.GetCountOf(typeof(MdlParagraph)));

//The data can contain either \r, \n or \r\n - these all must be converted to \r.
new string[] {“Field1”},
new object[] {“Paragraph 1\r\nParagraph 2\r\rParagraph 3\nParagraph 4.”});

//4 in the first cell, 1 second cell, 1 row and 1 section.
Assertion.AssertEquals(8, doc.Model.GetCountOf(typeof(MdlParagraph)));
Assertion.AssertEquals(“Paragraph 1\r”, doc.Model.GetParagraphAt(0).GetText());
Assertion.AssertEquals(“Paragraph 2\r”, doc.Model.GetParagraphAt(1).GetText());
Assertion.AssertEquals("\r", doc.Model.GetParagraphAt(2).GetText());
Assertion.AssertEquals(“Paragraph 3\r”, doc.Model.GetParagraphAt(3).GetText());
Assertion.AssertEquals(“Paragraph 4.\x0007”, doc.Model.GetParagraphAt(4).GetText());
Assertion.AssertEquals("\x0007", doc.Model.GetParagraphAt(5).GetText());

TestUtil.Save(doc, @“TestMailMergeWithCr Out.doc”);