Content controls made their debut in Office 2007, and each
version since has added new enhancements.
Office 2013 is no exception.
This version’s controls have four new improvements:

  • Visualization styles
  • Color
  • Support for XML mapping
  • A repeating control

I’ll review the two visual
enhancements — visualization styles and color — that improve readability and
usability when creating and using structured documents. You can download an example file, but you won’t need it to follow along. I included an example file because it contains the macro that’s in the For the developers section of this article.

Content
controls

A structured document is a document that controls where
content appears, and content controls are the main component of these documents.
You use these controls to simplify complex documents and to guide user input; you can also use them to position text that shouldn’t be moved or altered.
Word’s tool-of-trade for creating structured documents is the content control
palette.

Content controls store different types of data, such as
dates, lists, and even paragraphs of formatted text. Word 2013 supports the
following content controls:

  • rich text
  • plain text
  • picture
  • building block gallery
  • combo box
  • drop-down list
  • date
  • checkbox
  • repeating section (new to 2013)

Enhancements in Office 2013

Visualization styles let you customize the control’s
appearance. In Office 2010, controls display a boundary called a bounding box; in Office 2013, you can disable this line.

Figure A shows the older style and the new
possibilities. You can’t tell much difference because this figure shows what
the user sees before engaging a control. The enhancements let you customize
what the user sees when using the
control — that’s where all the flexibility comes into play. You’ll see those
properties in action as we work through these examples.

Figure A

 

 

By default, controls preserve the original look, back to
Word 2007:

  • When the control doesn’t have the focus, you see
    nothing but the control’s contents (or blank space).
  • When you mouse over, the content control
    displays a shaded rectangle.
  • When the content control has focus, it displays
    a bounding box (i.e., a line around the content) and the control’s title (if you add
    one).

The changes to Office 2013 controls let you choose three
states:

  • Bounding
    Box:
    The default is still available.
  • Start/End
    Tag:
    This state displays tags but not the title. Dropdown arrows and other
    buttons display when you mouse over.
  • None: This state displays nothing but the contents until you give the control focus, when it
    displays a shaded rectangle.

When you change the color, you’re changing the bounding box
and tags. A control set to None will let you set a color, but you won’t see it.

Exploring the possibilities

Let’s add a few controls, and see what they look like compared to the earlier versions. You’ll need to display the Developer tab if
you haven’t done so already.

1. Click the File tab.
2. Choose Options.
3. In the left pane, select Customize Ribbon.
4. In the Main Tabs list to the right, check the
Developer option (
Figure B).
5. Click OK.

Figure B

 

 

To insert a content control, click the Developer tab and then position your cursor where you want the control to appear. Next, click a
control option from the left side of the Controls group (see Figure A). We’ll
work with the Rich Text Content Control (it’s the first control in the first
row). To set the control’s properties, click Properties on the right side of the
Controls group and complete the following steps.

1. From the Show As dropdown, choose Start/End Tag (Figure C).

Figure C 

 

 

2. Below the Show As dropdown, click the Color
dropdown and choose a bright color that’s easy to see. In Figure D, you see I chose bright orange.

Figure D 

 

 

3. Before closing the dialog, enter a Title. I entered Tags to identify
this control’s state.

4. Click OK.

Because I chose the Start/End Tag option, you can see the
new color in the tags shown in Figure E, which the control displays at all
times. When you give the control focus, it displays a shaded rectangle.

Figure E

 

 

With the control selected, click Properties and change the
Start/End Tag option to None. Figure F shows this control after I added text.
You can’t tell the text is in a control; in fact, you might worry that
something’s gone wrong. To reassure yourself that the control really is in
place, click Design Mode in the Controls group — this will change the control’s appearance (Figure G). You can see the orange
tags and the title (Tags).

Figure F 

 

 

Figure G

 

 

For the developers

You can use VBA to set these new properties using the
ContentControl object’s new Appearance and Color members.

  • Appearance: wdContentControlBoundingBox,
    wdContentControlHidden, wdContentControlTags
  • Color: wdColorAqua, wdColorBlack, and so on

Listing A is a procedure that you can run as a macro
to insert a Start/End Tag content control that displays an aqua bounding box. After
running the macro, you can see the newly inserted control shown in Figure H.
This is a simple example, and you’ll want to explore these new members more
thoroughly.

Listing A

 

Sub InsertContentControl()
Dim objCC As ContentControl
‘Insert example content control using members new to 2013 object model.
Set objCC = ActiveDocument.ContentControls.Add(wdContentControlRichText)
objCC.Title = "Tagged Content Control"
objCC.Appearance = wdContentControlTags
objCC.Color = wdColorAqua
End Sub

Figure H 

 

Better than ever

These two new visual properties will make
using content controls easier for your users. You can use the state or color
options to make them more or less visible. The purpose of your structured
document will help you determine how to apply these new enhancements.

Next month, I’ll show how to use the new repeating
content control.