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