Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 12-16-2020, 02:17 PM
macropod's Avatar
macropod macropod is offline VBA to display and choose merge fields Windows 10 VBA to display and choose merge fields Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
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
 

Tags
macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to display and choose merge fields Displaying FORMTEXT fields when merge fields are empty or null sfkHooper Mail Merge 6 01-19-2016 04:24 PM
Pivot table - I cant display item labels when no fields in value area differentdrummer Excel 0 12-12-2013 05:13 PM
VBA to display and choose merge fields Can I have a dropdown list to choose from in mail merge? lawlaw Mail Merge 3 11-29-2012 04:47 PM
VBA to display and choose merge fields Conditional merge fields in mail merge Aude Mail Merge 1 01-06-2012 07:38 PM
How to display sort fields keith1952 Word 1 10-31-2011 05:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft