#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
Can you post an example of what you mean?
|
#3
|
||||
|
||||
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
macro |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Can I have a dropdown list to choose from in mail merge? | lawlaw | Mail Merge | 3 | 11-29-2012 04:47 PM |
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 |