<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

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

Published on
30,578 Points
20,078 Views
5 Endorsements
Last Modified:
Awarded
Community Pick
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 (http://dbe.codeplex.com/).

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 (http://dbe.codeplex.com/).

2

In Word 2007/2010, enable the Developer ribbon tab if it is not already enabled.
a. For Word 2007:
1. Select the Office button
040910-2213-UsingConten1.gif
2. Select Word Options
3. Click Popular and then select “Show Developer tab in the Ribbon”

b. For Word 2010:
1. Select File > Options
040910-2213-UsingConten2.png
2. Select Customize Ribbon and ensure the Developer option is marked.
040910-2213-UsingConten3.png

3

On the Developer Tab, be sure to select Design Mode for adding and editing form fields
040910-2213-UsingConten4.png

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)
040910-2213-UsingConten5.png
040910-2213-UsingConten6.png

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.
040910-2213-UsingConten7.png

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.
040910-2213-UsingConten8.png

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
040910-2213-UsingConten9.png

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.
040910-2213-UsingConten10.png

"<tagname />" will simply add the tag and not add any default value in the XML.

"<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
040910-2213-UsingConten11.png

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.
040910-2213-UsingConten12.png

14

Save the document.

15

Reopen the document in Microsoft Word and enter your information into the first linked field.
040910-2213-UsingConten13.png

16

You should see the text entered repeated in the other linked fields.
By using this technique, you can create very robust form-driven documents.  

Original Article: http://www.johnchapman.name/using-content-controls-to-repeat-form-fields-in-microsoft-word-2007-and-word-2010/
5
Comment
Author:chapmanjw
1 Comment

Expert Comment

by:Charles Kenyon
Great article. A much simpler method, although limited, is to use the already mapped document property content controls, such as the Company Name document property. These can be renamed and repurposed. See http://addbalance.com/word/MappedControls.htm for details.
0

Featured Post

Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Join & Write a Comment

In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Next Article:

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month