Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2021, 09:35 AM
wacobc wacobc is offline Remove blank lines in mail merge using table Windows 10 Remove blank lines in mail merge using table Office 2016
Novice
Remove blank lines in mail merge using table
 
Join Date: Aug 2021
Posts: 1
wacobc is on a distinguished road
Default Remove blank lines in mail merge using table

I am attempting to create an address/phone directory mail merge in Word, data source is Excel.
Like many others that have posted, I find that blank lines reside where there is no data in the source file - such as having 2 address lines but only 1 populated. I tried the \b "" trick - both with and without using a table. I cannot get it to work to remove the blank lines either way. I have attached files for both styles with the mail merge codes (\b trick is removed).


Is there a way to remove the blank lines other than manually after finishing the merge?
Attached Files
File Type: docx Address Book Merge File - No Table.docx (24.3 KB, 6 views)
File Type: docx Address Book Merge File - Table.docx (16.1 KB, 5 views)
Reply With Quote
  #2  
Old 08-19-2021, 09:10 PM
gmayor's Avatar
gmayor gmayor is offline Remove blank lines in mail merge using table Windows 10 Remove blank lines in mail merge using table Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Remove all the merge fields from your document(s) except those pertaining to the first record. Remove the Next Record field from the end of that record.

Conditionally insert the merge fields that might be empty e.g.on the end of the line above add the following. ¶ indicates a paragraph break.

{ IF { MERGEFIELD OTHER_RESIDENTS } <> "" "¶
{ MERGEFIELD OTHER_RESIDENTS } { MERGEFIELD ADDRESS_2 } { MERGEFIELD adult_2 } { MERGEFIELD C_PHONE_2 } { MERGEFIELD EMAIL2 }¶
"}

Then set the merge document type to 'Directory' and merge your selected records.

For the table version again use only the table for the first record (without the next record field) and then it would probably be better to remove the empty rows with a macro after merging as a directory merge e.g.
Code:
Sub DeleteEmptyRows()
Dim oTable As Table
Dim i As Integer
    For Each oTable In ActiveDocument.Tables
        For i = oTable.Rows.Count To 1 Step -1
            If Len(oTable.Rows(i).Range) = (oTable.Rows(i).Cells.Count + 1) * 2 Then
                oTable.Rows(i).Delete
            End If
        Next i
    Next oTable
lbl_Exit:
    Set oTable = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove blank lines in mail merge using table Mail Merge Template - remove blank rows in a table Litmus Mail Merge 16 03-23-2022 01:42 PM
Remove blank lines in mail merge using table Table Merge _ Auto Delete Blank Lines (without Data) Alex1s85 Mail Merge 7 05-04-2020 05:12 AM
Remove blank lines in mail merge using table Blank Lines in Mail Merge - Other Options not working cluyster1127 Mail Merge 13 12-11-2019 01:05 PM
Remove blank lines in mail merge using table I am getting blank lines with Mail Merge rtcary Mail Merge 1 01-20-2018 02:07 PM
Remove blank lines in mail merge using table Eliminating blank lines in mail merge (labels) BeerStud Mail Merge 1 11-28-2014 06:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:01 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