Microsoft Office Tutorials and References
In Depth Information
Mail Merge: Creating a User-Friendly List of Fields
' * * * * *¶
'As well as be double-clicking an entry in the list¶
Private Sub lstMergeFields_DblClick(ByVal Cancel As
'Insert the selected entry¶
ActiveDocument.Fields.Add Range:=Selection.Range, _¶
Type:=wdFieldMergeField, Text:=lstMergeFields.Text¶
End Sub¶
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
'Display the UserForm¶
' * * * * *¶
Sub InsertMergeFields()¶
'Variable declaration¶
Dim frmMergeFields As frmListFields¶
Set frmMergeFields = New frmListFields¶
Set frmMergeFields = Nothing¶
End Sub¶
It will be easiest to use this macro from a toolbar button or menu command. In
order to assign it to the mail merge toolbar:
1. Display the Commands tab in the Tools | Customize dialog box.
2. Select the Macros category.
3. Locate the InsertMergeField entry and drag it to the Mail Merge (or
any other) toolbar.
Every time the button is clicked, the list of merge fields is displayed.
To create the form shown in the graphic, the controls and their attributes
should be as follows:
Control Type:
Control properties
UserForm Name: frmListFields
Label Name:
List Box Name:
0 — frmMultiSelectSingle
Search JabSto ::

Custom Search