Microsoft Word and MailMerge fields RRS feed

  • Question

  • Hey Guys,

    I have a word template, dotx file. What I would like to add to it is a button/drop down list with about 20 fields/options the user can select. When the user selects the option, some text is inserted into the document. Those options will be things such as, title, first name, last name, address etc, similar to the insert mail merge field we already have but bear in mind I have not assigned a data source, file to my template. I just want this template to contain the facility to add mail merge fields without a datasource as I plan to parse the fields in my application to do the mail merge, but thats a different ballgame.

    Is there some resources someone can point me towards on how I can create/acheive this whether it be in the form of a button or an office addon?



    Thursday, January 14, 2016 2:36 PM


All replies

  • You could use content control dropdowns and/or combo boxes for the variable content. See, for example:

    You could even hold variable content in, say, an Excel workbook. See, for example:

    As for inserting mergefields, that ordinarily requires being connected to a data source; otherwise Word has nothing to tell it what the field names might be. That said, such fields can be constructed without recourse to a data source. To do that, you could press Ctrl-F9 to create a pair of field braces (which appear as '{ }'), then fill them in with code like 'MERGEFIELD MyField', so you get {MERGEFIELD MyField}. Select the field and press F9 and you'll then see «MyField». Alternatively, you could create them via Insert|Quick Parts|Field>MergeField>Field Codes.

    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by David_JunFeng Monday, January 25, 2016 5:49 AM
    Thursday, January 14, 2016 9:21 PM
  • Hi Paul,

    Thanks for replying. I tried using the content control dropdown. The dropdown had populated with all the field variables I wanted. The thing is, what I am looking for is having that dropdown perhaps somewhere in the ribbon or on the right hand pane of my document. When someone clicks on a value, I want it to insert it exactly where the cursor is. The more I think about it the more I think its a add in of some sort.


    Friday, January 22, 2016 2:01 PM
  • That's not how content controls work. What you're describing is a modeless userform, but you can't use mergefields in those (a userform could be used to insert a mergefield into a document, though). And, of course, when you click on anything in a userform, the mouse will be there, not in the document. For more info, see:

    Paul Edstein
    [MS MVP - Word]

    Friday, January 22, 2016 9:16 PM
  • From what you told us I would say that you either want to:

    - Create a macro using VBA and put the button to the Ribbon.

    - Or create an Add-In for MS Word that will run this functionality (using VSTO)

    For mail merge you can use Docentric Toolkit which is a .NET library mail merge library that can handle almost any requirement (placeholders in headers, footers, images, charts, lists...).

    Thursday, January 28, 2016 2:14 PM