Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2022, 06:43 PM
BernieB BernieB is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Novice
Suppress blank line in mail merge
 
Join Date: Mar 2022
Posts: 4
BernieB is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 03-04-2022, 08:04 PM
Charles Kenyon Charles Kenyon is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You could use:
Code:
{ IF { MergeField Address_1 } > "" "{ MergeField Address_1 }
"{ MergeField Address_2}
Reply With Quote
  #3  
Old 03-04-2022, 09:45 PM
macropod's Avatar
macropod macropod is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #4  
Old 03-05-2022, 07:56 AM
BernieB BernieB is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Novice
Suppress blank line in mail merge
 
Join Date: Mar 2022
Posts: 4
BernieB is on a distinguished road
Default

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
Reply With Quote
  #5  
Old 03-05-2022, 02:56 PM
macropod's Avatar
macropod macropod is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Instead of:

{MERGEFIELD Address_1 \f"
"}
{Address_2}

you should have:

{MERGEFIELD Address_1 \f"
"}{Address_2}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 03-06-2022, 04:52 PM
BernieB BernieB is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Novice
Suppress blank line in mail merge
 
Join Date: Mar 2022
Posts: 4
BernieB is on a distinguished road
Default 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
Reply With Quote
  #7  
Old 03-06-2022, 05:10 PM
macropod's Avatar
macropod macropod is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #8  
Old 03-06-2022, 05:49 PM
macropod's Avatar
macropod macropod is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by BernieB View Post
Another question: Is there a way to put the comma between City and Province somewhere else in case there is no City or Province?
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]
Reply With Quote
  #9  
Old 03-07-2022, 02:17 PM
BernieB BernieB is offline Suppress blank line in mail merge Windows 10 Suppress blank line in mail merge Office 2016
Novice
Suppress blank line in mail merge
 
Join Date: Mar 2022
Posts: 4
BernieB is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppress blank line in mail merge Making mail merge blank fill a line to highlight that line rgm60527 Mail Merge 2 02-22-2022 11:13 AM
Suppress blank line in mail merge Suppress paragraph mark in mail merge field acerview Mail Merge 3 12-22-2015 07:44 PM
Suppress blank line in mail merge Suppress comma in "city , stat zip" line when blank DHammer Mail Merge 1 05-30-2014 02:43 AM
Suppress blank line in mail merge Suppress blanks in mail merge 0nyx175 Mail Merge 11 01-07-2014 02:45 PM
Suppress blank line in mail merge Easy mail merge but want to suppress rows ClaireAMAdams Mail Merge 5 04-30-2013 02:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft