View Single Post
 
Old 08-19-2021, 09:10 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
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 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