RemoveEmptyParagraphs issue

I am experiencing a removal of the entire line of merge fields in my output document when the first of the 3 merge fields is set to null when I set RemoveEmptyParagraphs to TRUE.

My WORD merge document has the following on the same line.
<>, <> <>

When I leave out the City data, the entire line is removed from the resulting document, eventhough the other fields on that line have been supplied data.

When the merge fields are on a single line and the data is set to NULL, this is OK…

Any workaround or am I doing something wrong - or maybe this is expected behavior??

Hi,

RemoveEmptyParagraph removes whole paragraph (which in your case contains all mail merge fields) when it encounters at least one of the fields has no data. I agree it is a misnomer for your particular case and should be called something like RemoveParagraphWhenFieldIsEmpty.

RemoveEmptyParagraph was designed to help in this situation:
<>,


<>


<>




If you cannot split the address line into several lines in the document, then you can insert only one field in the document <> and build the value for this field either in the query, as a calculated DataTable column or in the MergeField event handler.

Doing it in the event handler will look something like this:

private void HandleMergeFieldEvent(object sender, MergeFieldEventArgs e)
{
if (e.FieldName == “Address”)
{
StringBuilder address = new StringBuilder();
//TODO Build your address string from the data in your table.
e.Text = address.ToString();
}
}