Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2020, 02:30 AM
JamesWood JamesWood is offline VBA to display and choose merge fields Windows 10 VBA to display and choose merge fields Office 2019
Advanced Beginner
VBA to display and choose merge fields
 
Join Date: Nov 2020
Posts: 37
JamesWood is on a distinguished road
Default VBA to display and choose merge fields

Hi guys


If you have some merge data loaded into a Word doc, is there any way you can run a macro that displays the available fields (in a box/pop up) from the data and allows you to click on one, and that then determines a string in the background (for another part of the macro)?


Thanks a lot!


James
Reply With Quote
  #2  
Old 12-15-2020, 11:56 PM
Purfleet Purfleet is offline VBA to display and choose merge fields Windows 10 VBA to display and choose merge fields Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

Can you post an example of what you mean?
Reply With Quote
  #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: 21,956
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
Reply

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 01:38 AM.


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