View Single Post
 
Old 12-16-2020, 02:17 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Here's some code to get you started. As coded, the macro simply outputs the list of available fields to a message box.
Code:
Sub GetAllMergeFields()
Dim MMDF As MailMergeDataField, StrFlds As String
With ActiveDocument
  If .MailMerge.MainDocumentType = wdNotAMergeDocument Then Exit Sub
  For Each MMDF In .MailMerge.DataSource.DataFields
    StrFlds = StrFlds & vbCr & MMDF.Name
  Next
End With
MsgBox StrFlds
End Sub
To be able to select from the list, you'd need to output it to some kind of dropdown or listbox.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote