Remove Merge Field

Is there a way to remove a merge field, when setting up a HandleMergeField event. For example, I want to test to see if there is no data in the merge field, and if there is no data, delete the merge field. This could remove a blank line for an address, for example.

Derek

I believe the answer would be e.FieldName.Remove - is that correct? Is that an efficient way to remove a line in a document, for an address, for example?

No, you just need to set e.Text = "" . The field is automaticaly removed after MailMerge occured. You can also use MailMerge.DeleteFields to remove all fields which were not merged due to some reason. For example, if their names were absent from the MailMerge data source.

Another way is to set MailMerge.RemoveEmptyParagraphs property to true before MailMerge execution. This property controls whether paragraphs that contained mail merge fields with no data should be removed from the document.

OK, one subtle item. If I use RemoveEmptyParagraphs, how could I force a paragraph marker to stay there if I did want it. I tried sending in one blank space, but it still seems to disappear. Any clever ways to do this; make one character and make the text color white, or something like that...

Derek

To prevent paragraph with merge field from removal you need to have at least one character in this paragraph besides merge field. For example, you can put one space character after merge field but before paragraph mark.