Search code examples
vb.net.net-4.0ms-wordmailmerge

Help Using Word 2002 MailMerge to not display if value is blank


I am using VB.net 2010 to generate a letter from a Word 2002 template. The template has MailMerge bookmarks where the database values will be displayed (for example the letter receiving company's address). Currently I have:

«Company Contact»
«Company Name»
«Address1»
«Address2»
«City», «State», «ZipCode»

If "Address2" value is blank, then don't display the bookmark in the letter output (hence avoid displaying a blank line)

How can I go about doing this?


Solution

  • Use an <<AddressBlock>> instead of using the individual merge fields. Empty values will be suppressed. http://office.microsoft.com/en-us/word-help/field-codes-addressblock-field-HP003069839.aspx