Creating a Form with Content Controls
As previously explained, content controls work only in Word 2007 and higher documents and templates. They look nice, and they are easy for users to understand and use. You can apply formatting styles to them, and you can prevent them from being edited or deleted.
Inserting a Content Control
To insert a content control, follow these steps:
- Position the insertion point where you want the new control.
- On the Developer tab, make sure Design Mode is selected.
- Click one of the content control buttons on the Controls group to insert it into the document.
There are eight content controls you can insert, summarized in Table 16.6. On the Developer tab’s Controls group, point to a button to determine which content type it represents.
Table 16.6. Content Control Types
Control |
Purpose |
Rich Text |
Holds text that the user can optionally format (bold, italic, and so on). |
Plain Text |
Holds plain text that the user cannot format. |
Picture |
Holds a picture that the user inserts. |
Building Block Gallery |
Inserts a placeholder from which the user can select a building block from a gallery you specify. |
Combo Box |
Displays a list of values from which the user can select, and allows the user to enter other values. |
Drop-Down List |
Displays a list of values from which the user can select. Other values are not permitted. |
Date Picker |
Displays a calendar from which the user can click a date. |
Check Box |
Displays an on/off check box toggle. |
Configuring a Control
A content control is generic after insertion; you must provide its context via its Properties box. To view the Properties for a control, select it and then click the Properties button in the Controls group on the Developer tab.
Settings Common to All Control Types
The options available in the Properties dialog box depend on the control type, but all controls have a Title box, in which you specify the text that should appear in the bar across the top of the control. Figure 16.7shows a photo with a title of January, for example.
Figure 16.7. A content control for a picture and its Properties dialog box.
These settings are available, as shown in Figure 16.7, regardless of field type:
- Show As—This drop-down list enables you to choose how the field appears in the document. The default is Bounding Box, which is a large box around the control; the alternatives are Start/End Tag, which displays graphical brackets around the field, and None, which makes the field content look like regular text or graphics in the document.
- Remove Content Control When Contents Are Edited—This option deletes the field placeholder after the user enters content into it, leaving only the content as a regular part of the document.
- Content Control Cannot Be Deleted—This prevents users from deleting the control.
- Contents Cannot Be Edited—This prevents users from changing what they enter in the control after the initial entry.
Style Options
By default, a field takes on the paragraph formatting of whatever paragraph you place it in. For some field types, though, you can override this formatting by applying a different style to the field entry.
For Rich Text, Plain Text, Combo Box, and Drop-Down List, you can mark Use a Style to Format Text Typed into the Empty Control and then select a style from the Style list (see Figure 16.8). You can also click New Style to create a new style on-the-fly for it.
Figure 16.8. For text fields, you can specify a style to apply.
Multiparagraph Text Options
For a plain text field only, you can choose Allow Carriage Returns (Multiple Paragraphs). This option enables users to press Enter to start a new paragraph within the field. This option is not available for rich-text fields because they always allow this.
List Options
Combo boxes and list boxes enable you to set up the list that appears when the user activates the control. In the Drop-Down List Properties area of the Content Control Properties dialog box, follow these steps:
- Click Add. The Add Choice dialog box opens.
- Enter the Display Name. This is the text that appears on the screen.
- Enter the Value. This is what you enter into the database if you are connected to the form; otherwise, this is just stored with the field (see Figure 16.9).
Figure 16.9. Set up a list from which users can select.
- Click OK.
- Repeat steps 1–4 to add more choices to the menu.
- (Optional) Modify the list by doing any of the following:
- To modify an entry, select it, click Modify, make changes, and click OK.
- To delete an entry, select it and click Remove.
- To reorder the list, select an item and click Move Up or Move Down.
- Click OK.
Date Options
For a date field, you can control these four settings, as shown in Figure 16.10:
- Display the Date Like This—Select a format from the list provided.
- Locale—Select a country and language.
- Calendar Type—Select a type based on your country. In the United States and most of Europe, the calendar is Western.
- Store XML Contents in the Following Format When Mapped—This setting is important only if you will be connecting to an XML data source. Select from the list of formats provided.
Figure 16.10. Set date options for a Date content control.
Check Box Options
For a check box, you can control how the box appears when it is checked and when it is unchecked.
To control the appearance, from the Properties dialog box for the control, click the Change button next to Checked Symbol or Unchecked Symbol. Then, select a new symbol from the Symbol dialog box that appears. You do not have to use square boxes; you can have it appear as any character or symbol you like (see Figure 16.11).
Figure 16.11. Select a different symbol to represent the marked and unmarked check boxes.
Building Block Options
The same versatile building blocks that you have learned about in other chapters are available for use in forms. For example, you can access any built-in or custom galleries such as Equations, AutoText, and Quick Parts.
The implications of this capability are significant. For example, suppose that you have a set of boiler-plate paragraphs that you want to be able to select among when composing letters. You could place a Building Blocks field in your template and then have easy access to those paragraphs by clicking that field whenever you are creating a new letter.
The default building block content control doesn’t do anything at first; you have to set it up to be associated with a certain gallery and category. To set that up, choose a gallery and category from the Document Building Block Properties.
To learn more about building blocks, including how to create your own categories, see “Working with Building Blocks, p. 86.
Editing Placeholder Text
The placeholder text for a content control is the text that appears inside the box by default, with instructions such as Click here to enter text. If you like, you can customize the wording of that instruction so that it is different for each field. For example, for a control that holds first names, you could change it to Click here and type your first name.
To edit a placeholder, follow these steps:
- On the Developer tab, click the Design Mode button to turn on Design Mode if it is not already on.
- Click inside the control, where the placeholder text is, and edit the placeholder text there.