#1
|
|||
|
|||
Suppress blank line in mail merge
Hello,
I am using a Directory in Word to generate a document. I am trying to remove the line break if the Address_1 field is empty. I tried using the switch \b but it's not working. Here is the code I used: {QUOTE{IF{MERGESEQ}=1 {SET Key ""}}"{IF{MERGEFIELD Organization} <>{REF Key \*MERGEFORMAT} "{IF{MERGESEQ}>1 ""}{QUOTE 12} {MERGEFIELD Organization} {MERGEFIELD Name \*MERGEFORMAT}{SET Key{MERGEFIELD Organization}}" {MERGEFIELD Name}} {MERGEFIELD Title} {Address_1 \b} {Address_2} {City}, {Province} {Postal_Code}"} Any help is greatly appreciated! Thank you, Bernie |
#2
|
|||
|
|||
You could use:
Code:
{ IF { MergeField Address_1 } > "" "{ MergeField Address_1 } "{ MergeField Address_2} |
#3
|
||||
|
||||
For a more efficient way, see Mailmerge Empty Line Suppression in the Mailmerge Tips & Tricks 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thank you Charles, it worked!
Here is my code now: {QUOTE{IF{MERGESEQ}=1 {SET Key ""}}"{IF{MERGEFIELD Organization} <>{REF Key \*MERGEFORMAT} "{IF{MERGESEQ}>1 ""}{QUOTE 12} {MERGEFIELD Organization} {MERGEFIELD Name \*MERGEFORMAT}{SET Key{MERGEFIELD Organization}}" {MERGEFIELD Name}} {MERGEFIELD Title} {IF {MERGEFIELD Address_1} > "" "{MERGEFIELD Address_1} }" {Address_2}" {City}, {Province} {Postal_Code}} Dear Paul, I kept trying to get either the \b or \f switches to work but I am still getting a blank line. Here is what I tried (either the \f or the \b): {QUOTE{IF{MERGESEQ}=1 {SET Key ""}}"{IF{MERGEFIELD Organization} <>{REF Key \*MERGEFORMAT} "{IF{MERGESEQ}>1 ""}{QUOTE 12} {MERGEFIELD Organization} {MERGEFIELD Name \*MERGEFORMAT}{SET Key{MERGEFIELD Organization}}" {MERGEFIELD Name}} {MERGEFIELD Title} {MERGEFIELD Address_1 \f" "} {Address_2}" {City}, {Province} {Postal_Code}} Thank you both so much for your help. Paul your guides are amazing! Bernie |
#5
|
||||
|
||||
Instead of:
{MERGEFIELD Address_1 \f" "} {Address_2} you should have: {MERGEFIELD Address_1 \f" "}{Address_2}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Remove blank line from Directory MailMerge
Thank you Paul!
Yes this worked great and easier than IF statements. My code now looks like this: {QUOTE{IF{MERGESEQ}= 1 {SET Key ""}}"{IF{MERGEFIELD Organization} <> {REF Key \* MERGEFORMAT } "{IF{MERGESEQ}> 1 ""}{ QUOTE 12 } {MERGEFIELD Organization \* MERGEFORMAT } { MERGEFIELD Name \* MERGEFORMAT }{SET Key {MERGEFIELD Organization }}" { MERGEFIELD Name }} { MERGEFIELD Title \f" "}{ MERGEFIELD Organization2 \f" "}{ MERGEFIELD Address_1 \f" "}{ MERGEFIELD Address_2 \f" "}{ MERGEFIELD City }, { MERGEFIELD Province } { MERGEFIELD Postal_Code }} Another question: Is there a way to put the comma between City and Province somewhere else in case there is no City or Province? Thank you, Bernie |
#7
|
||||
|
||||
To see what can be achieved with Word's Catalogue/Directory Mailmerge facility, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial in the 'Sticky' thread at the top of this forum:
https://www.msofficeforums.com/mail-...-tutorial.html The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it. Depending on what you're trying to achieve, the field coding can be complex. However, since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire. For some worked examples, see the attachments to the posts at: https://www.msofficeforums.com/mail-...html#post23345 https://www.msofficeforums.com/mail-...html#post30327 Another option you might consider would be to use a DATABASE field in a normal ‘letter’ mailmerge main document and a macro to drive the process. An outline of this approach can be found at: https://answers.microsoft.com/en-us/...1-1996c14dca5d Conversely, if you're using a relational database or, Excel workbook with a separate table with just a single instance of each of the grouping criteria, a DATABASE field in a normal ‘letter’ mailmerge main document could be used without the need for a macro. An outline of this approach can be found at: https://answers.microsoft.com/en-us/...f-8642e46fa103 For some working examples, see: https://www.msofficeforums.com/mail-...-multiple.html https://www.msofficeforums.com/mail-...tml#post151706 https://www.excelforum.com/excel-gen...ml#post5110813 (the second of these uses a macro to apply some additional formatting). The DATABASE field can even be used without recourse to a mailmerge. An example of such usage can be found at: https://www.msofficeforums.com/mail-...html#post67097
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
||||
|
||||
You could conditionally insert the comma and its space into the Province output using the \b switch. See the Mailmerge Empty Space Suppression topic in the Mailmerge Tips & Tricks thread.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Yes, that is perfect!
{QUOTE{IF{MERGESEQ}= 1 {SET Key ""}}"{IF{MERGEFIELD Organization} <> {REF Key \* MERGEFORMAT } "{IF{MERGESEQ}> 1 ""}{ QUOTE 12 } {MERGEFIELD Organization \* MERGEFORMAT } { MERGEFIELD Name \* MERGEFORMAT }{SET Key {MERGEFIELD Organization }}" { MERGEFIELD Name }} { MERGEFIELD Title \f" "}{ MERGEFIELD Organization2 \f" "}{ MERGEFIELD Address_1 \f" "}{ MERGEFIELD Address_2 \f" "}{ MERGEFIELD City }{ MERGEFIELD Province \b ", "} { MERGEFIELD Postal_Code }} Thanks again, Bernie |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Making mail merge blank fill a line to highlight that line | rgm60527 | Mail Merge | 2 | 02-22-2022 11:13 AM |
Suppress paragraph mark in mail merge field | acerview | Mail Merge | 3 | 12-22-2015 07:44 PM |
Suppress comma in "city , stat zip" line when blank | DHammer | Mail Merge | 1 | 05-30-2014 02:43 AM |
Suppress blanks in mail merge | 0nyx175 | Mail Merge | 11 | 01-07-2014 02:45 PM |
Easy mail merge but want to suppress rows | ClaireAMAdams | Mail Merge | 5 | 04-30-2013 02:43 PM |