Using Content Controls to Repeat Form Fields in Microsoft Word 2007 and Word 2010

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than manually entering the company name into every place it is needed. This helps greatly to ensure fewer errors and improves efficiency when users fill out the form.

In Word 2003 and prior this could be done by inserting a form field and then referencing it as a book mark. In that scenario, the designer of the form would add the field once and mark it to be bookmarked in the field properties. Then wherever the field would need to be repeated they could hit CTRL-F9 and then enter “{ REF fieldname }” to reference the field. This method still works in Word 2007 and 2010. However, it uses the “legacy” form controls and does not allow you to take advantage of the new controls, such as the date chooser. The legacy reference technique also only allows the user to fill in the information in one field; they cannot enter it into just any of the occurrences throughout the document and have it update the rest.

In Word 2007 and 2010, it is no longer possible to simply bookmark the form control and cross-reference it later in the document. However, since the Word 2007+ (.docx) format is now XML-based, the new Content Control features can be used to reference information in the XML structure. And even better, that XML structure is fully customizable in a rather easy manner.

To customize and word with the XML associated with these controls, there is a free application called the Word Content Control Toolkit. It can be downloaded from CodePlex.

The following steps are a quick tutorial on using this tool and creating a simple form that ties multiple fields together with the same value:

  1. Download and install the Word Content Control Toolkit from CodePlex.
  2. In Word 2007/2010, enable the Developer ribbon tab if it is not already enabled.
    1. For Word 2007:
      1. Select the Office button

      2. Select Word Options
      3. Click Popular and then select “Show Developer tab in the Ribbon”
    2. For Word 2010:
      1. Select File > Options

      2. Select Customize Ribbon and ensure the Developer option is marked.

  3. On the Developer Tab, be sure to select Design Mode for adding and editing form fields

  4. Insert a few form fields to create your simple form.
  5. For each field, edit the Properties to give a meaningful name (I usually also select “Content control cannot be deleted” to ensure the form stays intact).




  6. My simple form has the Company Name repeated twice. The end goal is to have the ability to edit either field and have it update the other.

  7. Save the document and close Microsoft Word
  8. Open the Word 2007 Content Control Toolkit and open the document you just saved in Microsoft Word.

  9. You will see the two fields listed on the left under Content Controls. On the right, select “Create a new Custom XML Part”.
  10. Make sure you are in the Edit View and not the Bind View

  11. Using basic XML, we will create the XML tag “<company />” where the Company name will be stored. You can add as many of these as you would like as well as add sample text if you wish.

    1. “<tagname />” will simply add the tag and not add any default value in the XML.
    2. “<tagname>Default Value Text Goes Here</tagname>” – entering the default text inside the tag will set the default value if desired
  12. There is no set limit to the number of tags you can add

  13. After adding the desired tags, switch to the Bind View. You now need to associate these XML fields with the form fields. To do so, select the tag node in the bind view and drag it to the associated Content Control on the left.

  14. Save the document.
  15. Reopen the document in Microsoft Word and enter your information into the first linked field.

  16. It repeats the text as described and is good to go.

By using this technique, you can create very robust form-driven documents. If you have any questions or concerns, feel free to use the comments below.

  • Share/Bookmark
Print

Facebook Comments

  1. Dark_Angel511
    April 25th, 2010 at 20:03
    Reply | Quote | #1

    Thanks for the guide, really helped me a lot with repeating controls on Word 2007.

  2. April 25th, 2010 at 22:01
    Reply | Quote | #2

    Glad it helped :D

  3. Felipe
    May 5th, 2010 at 07:55
    Reply | Quote | #3

    I test the content control toolkit and it works great. But unfortunately, making many changes on a Text Content Control with the another binding fields and closing and opening the document, it does the document does not save the last changes.

    What can be happening?

    Thanks.

    • May 5th, 2010 at 08:30
      Reply | Quote | #4

      Felipe,

      If I understand correctly, you have used the toolkit to bind your fields and then made changes in Word to those fields? The issue might be that Word breaks the binding after making changes to a field and saving. After making changes to a bound field, you may just need to go back into the toolkit and rebind it to the XML field.

      Thanks,

      John

      • Peter
        June 1st, 2010 at 22:32
        Reply | Quote | #5

        I am having the same issue. I have the forms setup as instructed, however I will fill out the form, save it as another file name. Reopen the file I just saved, and all the fields I have selected as repeat forms are not filled in with any of the information. the rest of the form fields are still populated with the data I filled in. It is just the repeatable fields that are clearing out. I tried rebinding as suggested, but still same problem. Any other suggestions?

        • June 2nd, 2010 at 14:29
          Reply | Quote | #6

          Hello Peter,

          To rule out the XML changes due to the i4i lawsuit, are you using Word 2007 or Word 2010? And if you are using 2007, when did you obtain it (before or after Jan 1, 2010)?

          Thanks,

          John

        • June 2nd, 2010 at 14:44
          Reply | Quote | #7

          In Word 2010, I am not able to reproduce the issue. I tested by creating three fields, two of them bound together. I fill out the form and save it as another file name and the content remains when I reopen it.

          If you have a file that I can try to troubleshoot, send me a message through the Contact page and then Ill have you email it to me.

          Thanks,

          John

          • Peter
            June 15th, 2010 at 21:44
            Quote | #8

            I am using Word 2010. I created a sample document and will send to your via email. Let me know if you can fix my issue.

            Again, once I type in the info it repeats through the document to areas I specify, however when I save it and reopen it resets back to blank entry. If I input again, and then save it once more, reopen, the data stays. I have to always save it a second time to have the data stay which can be annoying.

  4. May 25th, 2010 at 04:28
    Reply | Quote | #9

    Came across you site and have gained so much in such a short time, Awesome, Awesome, Awesome.

    This site ranks as one of my favorites now.

  5. Michael
    June 11th, 2010 at 08:42

    Enter your comments here…The 15 built in document property content controls can be copied to a second document, and then repeated through out the second document and still work. The content controls crated with the Word Content Control Toll Kit, when copied to a second document, and then repeated in that second document do not work. Is there a way to make the Word Content Controls created with the tool kit be copied into a second document and then be repeated. This would allow a master form of content controls to be developed for say about 150 different forms which use content controls from the master. Additionally, once one form’s content controls are filled-in a second document with many of the same content controls can be brought into the first document and content controls in common are automatically complated without having to refill-in controls already completed.

  6. Lexter
    August 31st, 2010 at 07:59

    could tell me if Microsoft Word 2010 offers the ability to design electronic fillable forms as opposed to manual fill-in forms