Multiline mail merge fields- paragraph break problem

Hi

This may be a rockie question, but I cannot seem to find the answer within the forums.

I have a mail merge field that contains the addresses for people. This field contains line breaks as the address consists of multiple rows. My problem is that instead of just a new line, I get a paragraph break between each row which obviously isn't pretty.

What can I do about it?

I quickly looked at AddressBlock in Word, but it may not work for me since my addresses can be a mix of various international addresses.

Can the mailmerge field somehow replace a paragraph break with a new line?

Can I put a "newline character" in my address data instead of paragraph break? I currently concatenate address parts in a SQL-query and use CHAR(13) + CHAR(10) to create new lines. Is there another character I can use that does not render as paragraph break in Word?

Grateful for assistance,

!Rob

Hi Rob,


Thanks for your inquiry.

Could you please attach your template and code here for testing? Most likely you are asking about repeating a region within the same paragraph, but we need to be sure before we can give further advise.

Thanks,

Hello

I have attached a super simple test project where you can see what I mean.

Aspose.Words.

License license = new Aspose.Words.License();

license.SetLicense(

"Aspose.Total.lic");

DataTable dt = new DataTable();


dt.Columns.Add(

new DataColumn(“Address”, System.Type.GetType(“System.String”)));


dt.Rows.Add(

new Object[] { “Level 12\n225 Easthill Drive\nRobina QLD 4226\nAustralia” });

Document doc = new Document("…\…\ParagraphBreakProblem.docx");


doc.MailMerge.Execute(dt);
doc.Save(

"…\…\ParagraphBreakProblem Result.docx", Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Docx));

System.Diagnostics.

Process.Start("…\…\ParagraphBreakProblem Result.docx");

Because of the new line \n characters in the address string Word creates paragraph breaks. I would like it to be simply new lines (shift-enter).

How can that be achieved?

Regards,

!Rob

Hi Rob,


Thanks for this additional information.

To achieve what you are looking for you can just replace any instance of “\n” with “\v” in your input data.

If we can help with anything else, please feel free to ask.

Thanks,

Hi

That worked like a charm. I changed my T-SQL code to separate the address rows with CHAR(11) instead of CHAR(13).

Thanks for the quick and spot-on reply.

Regards,

!Rob