Create Mapped Content Controls

Home Up Odds & Ends Photo Gallery Search Contact Me

 

 

The information in this website is provided without risk or obligation and free of charge.  However, if you have benefitted from my efforts here and would like to make a contribution to help me continue and maintain this work then any donation will be greatly appreciated. Please click the adjacent button to access PayPal.  Thank you.
 

My Repeating Data Word Help and Tips page describes several methods that enable a document user to type data in one place and have it repeated (or populated) in one or more other places in the document.  One of the most powerful and versatile methods is the Content Control introduced in Word2007 that can be mapped to XML data stored in the document.

The designer's of Word2007 obviously saw the benefit of this method because they were nice enough to incorporate fifteen builtin, mapped controls into every new document.  These controls correspond to the fifteen builtin "document properties" from previous versions of Word.  In fact they are still called "document properties!"

To view and use one of these controls you simply click the Insert tab>QuickParts> and select the property you want to insert.  In the example shown below, I inserted the "Author" document property.

You can confirm that this "document property" is displayed to the user in a Content Control by selecting the the control then clicking the Developer Tab>Controls>Properties.  The dialog displayed shows the control properties including the title "Author." 

Each of the fifteen (15) builtin document properties are mapped to a builtin customXMLPart of the document Office Open XML File format.  As explained in  Repeating Data if you copy and paste one of the controls to a different location in the document then the copy is also mapped to the same XML data.  Changes made to in the XML data, the original control, or to one or more copies are automatically reflected in in all the other mapped locations.
There would be no need for this tips page if the need to map data could be met in every document with just fifteen pre-defined controls.  We all know that is not the case.   Repeating Data explains this and provides several workarounds including steps for creating and mapping your own controls.
This tips page provides a Word AddIn that does all the work for you and allows you to create multiple mapped content controls with just a few mouse clicks.  The AddIn is created using a multipage Userform.  Features are described below with illustrations.
The Addin customizes the Word Ribbon and adds a command group and two command icons to the Add-Ins Tab.

The first screen allows the document designer to insert a text, dropdown, combobox, date, or picture content control. 

The Addin requires you to designate a URI Namespace (upon mapping the first control only) and a unique title for each content control that your create and map.  The control can be locked for content changes or protected from inadvertent deletion. 

Text controls can be enabled for multiple lines. 

If the control is created in a template file (.dotx or .dotm), the document designer can create a building block entry from the control.

Confession:  This AddIn started from a small piece of code I had worked on a year or so previously that simply created a building block entry from a selected content control.  That is why it is included here. I think it is easier to simply copy and paste the control so this feature doesn't have much practical value.

Note:  This AddIn can only be used in documents created in Word2007 using the Office Open XML File format.  For this reason and to prevent errors, you must first save a new document with a docx, docm, dotx, or docm format before using the AddIn.

The AddIn provides the interface for assigning the list members of dropdown and combobox controls. You can add members, remove members, or rearrange members.

The AddIn provides simple interface to delete content controls, clear content, and delete mapping.

Note:  This AddIn uses the content control "title" as the data key for most operations involving a deletions.  Only titled and mapped CCs will appear in the list of content controls.  However, if user adds a content control using the developer tab that has a title that matches a mapped control that control will be processed (i.e., deleted) using this AddIn.

It is really quite simple.  You just add the mapped control and then copy the control to as many place as you want to repeat the data.
The Add-In is provided here in a zip file format.  You can download Create and Map Content Controls to your Word Templates directory and load it using Developer>Templates.  For more on Add-Ins and how to load them, see the heading "Organizing Global Templates" at:    Organizing Your Macros

Looking for something else?

Google