View Single Post
 
Old 09-02-2019, 01:12 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
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

It is difficult to understand the point of this, but the following macro will work, provided you attach the datasource to the blank document:
Code:
Sub Macro1()
Dim i As Integer
Dim orng As Range
    With ActiveDocument.MailMerge.DataSource
        For i = 1 To .FieldNames.Count
            Set orng = ActiveDocument.Range
            orng.Collapse 0
            orng.Fields.Add orng, wdFieldMergeField, Chr(34) & .FieldNames(i), False
            Set orng = ActiveDocument.Range
            orng.Collapse 0
            orng.InsertParagraphAfter
        Next i
    End With
    Set orng = Nothing
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