Chapter 27. Customizing Documents with Content Controls

OFTEN when we’re planning documents, we typically think about what we want to include today on the page. We’re trying to meet a specific goal—like inspire people to increase their donations this year, or enticing folks to come take a closer look at our product Web site. But the content you create can live beyond the purpose you’ve planned for today’s documents. And in some cases, a document that meets today’s goal would be made even better if you added room for variable information—or interactive elements—that engage your readers. Word 2010 content controls can help you build that kind of functionality into your pages, and although it takes a bit more planning, the whole process is nearly as simple as point-and-click.

If you previously read the chapter on mail merge (Chapter 26), you remember that part of that process involves choosing the data items you want Word to insert in your document. Those items were actually content controls, the variable tools Word uses to gather and display the data that merges with—or changes—your pages. This chapter introduces you to content controls and shows you how to add them to your document.

Understanding the Word 2010 Content Controls

Previous versions of Word included a collection of form controls used to add form fields to documents. With form fields, you can, for example, create an invoice document, a travel expense report, or a registration form that a user could fill out electronically and submit. The data was saved with the document and could then be used in other data applications. Those form controls are still available in Word 2010—but now they are referred to as Legacy Form controls.

The content controls in Word 2010 give readers control over the type of content displayed in a document, populating specific selections based on the choices that they make. Someone reviewing your document can click a content control item at the top of your annual report, choose their name from the list, select the date, and leave a comment before they save and close the document. Content controls are XML-based, which means that the data and the presentation of the data can be stored separately.

When might you use content controls in your Word documents? Here are a few ideas:

  • You are creating a training document with a short quiz at the end to evaluate if organization volunteers have learned key elements of your program.

  • You want to add a routing system to standardized documents that automatically shows the user who to send their report to once it is finished.

  • You want to create a boilerplate template for a document you plan to create often that includes all the styles and formats already applied.

  • You need to standardize the documents used across your organization to streamline the way information is collected, shared, and used in your business processes.

Creating the Document

You can create the document that you want to use with content controls in one of three ways: you can start with a Word template (most templates include content controls of some kind), modify an existing document, or create a new document from scratch.

You can choose to add the content controls first and then drag them to any point in the document where you want them to appear, or you can create the body of the document—with its theme, styles, and illustrations, as appropriate—and then add the content controls last. Either way, the process is straightforward.

Displaying the Developer Tab

Your first step in creating a document that includes content controls involves displaying the Developer tab. The Developer tab is hidden by default because its function is specialized. To display the Developer tab, follow these steps:

  1. On the File tab, click Options.

  2. Click Customize Ribbon and, in the column on the right, select the Developer check box then click OK.

The Developer tab appears on the far right side of the Ribbon, as you see in Figure 27-1.

The Developer tab includes the tools to add content controls to your documents.

Figure 27-1. The Developer tab includes the tools to add content controls to your documents.

The Developer tab includes six different groups:

  • Code. This group includes the tools you’ll use to record macros, and write and edit Microsoft Visual Basic for Applications code.

  • Add-Ins. With this group you can set up any add-ins you use with Word, using the Add-Ins or COM Add-Ins tools.

  • Controls. The Controls group contains the Content Controls you add to the document. From within this group, you can add a number of different control types (including Legacy Controls and ActiveX controls), change to Design Mode, modify control properties, and group controls.

  • XML. This group includes tools for displaying the XML structure of the current document, adding an XML schema, attaching transforms, and adding expansion packs.

  • Protect. The Protect group offers only one tool—Protect Document—which displays the Restrict Formatting And Editing task pane so that you can control the permissions that others have to modify your document.

  • Templates. The Templates group includes a single tool—Document Template—which you use to add templates, schemas, and other add-ins to the current document.

Adding and Formatting Static Text

The beauty of content controls is that they are so easy to use; the process feels just like creating an ordinary document. The content controls simply add to the functionality of the document and elevate it beyond a flat, read-it-once-and-put-it-away purpose. Now you can read the document, respond to questions or information items, or add to the information by selecting your choices within the body of the document. In this way, a simple document becomes “smart.” Here are a few examples of ways you can transform a traditional document into a document that makes use of content controls:

  • In a document that helps prepare your volunteers or staff members for travel, you might want to use the first page as an information-gathering section in which the user enters information items such as Name, Address, Phone, and more. Additionally, you’ll record travel and passport information. On the next page, you might want to include a how-to guide to travel reporting, country-specific sight-seeing tips, or information about customs in the area.

  • In a document you’re preparing that describes your plan for an upcoming project, you will include the purpose for the project, an overall description, as well as a list of team members and contact info, and areas on the form for the various tasks and stages in the project. The list of team members, their contact items, and their assigned tasks can all be placed in content controls, so the information for the team members is continually updated and in sync with your organization’s data (see Figure 27-2).

  • In the patient records in your small medical office, you have a number of items that would appear on a traditional form—such as name, birth date, address information, and social security number—but you also want to include your privacy policy and other information related to your practice in the file. In this way, the traditional form and document merge to become one: easy to update, track, and secure.

    You can easily add a team contact form in your shared document using content controls.

    Figure 27-2. You can easily add a team contact form in your shared document using content controls.

You might want to simplify the form’s formatting by choosing a theme and then assigning specific Quick Styles to the various elements. You can also add Quick Parts, objects, photos, and more to spruce up the form any way you’d like. If you have designed letterhead for your company and want the form to resemble your other business documents, you can use the letterhead as the basis for your form. Figure 27-3 shows several formatting enhancements that have been added to the team information form.

You can add formatting enhancements to the form to give it professional appeal.

Figure 27-3. You can add formatting enhancements to the form to give it professional appeal.

Adding Content Controls

Content controls are so simple and flexible that you can add them at any point during the creation of your document. If you want to add them as you type, go ahead—you can just drag them to the point in the document you want them to be used. If you decide later that you want to move the control to a new spot, simply drag it there.

Here’s a quick list of ways readers of your document can use the content controls you enter to provide information:

  • Enter simple text in a comment box

  • Choose from among a series of options in a list

  • Select one of several pictures to cast votes for their favorite new logo design

  • Add their own information in addition to the list items presented

  • Select a date they choose from a visual calendar

  • Format the text they enter on the form

You’ll find everything you need to add those items to your form in the Controls group on the Developer tab. Table 27-1 gives you an introduction to the various commands, and the sections that follow provide more detail on each control type.

Table 27-1. Word 2010 Content Controls

 

Name

Description

Word 2010 Content Controls

Rich Text

Users can enter text with most types of formatting, as well as tables and images

Word 2010 Content Controls

Plain Text

Accepts plain text or text with simple formatting only

Word 2010 Content Controls

Picture

Use this control to add a picture to the form

Word 2010 Content Controls

Combo Box

Creates a text list in which the user can edit list items unless you specify otherwise

Word 2010 Content Controls

Drop-Down List

Lets you create a list in which the items are non-editable

Word 2010 Content Controls

Date Picker

Adds a calendar object so users can select a date

Word 2010 Content Controls

Check Box

Add a check box control to the page

Word 2010 Content Controls

Legacy Tools

Displays a palette of tools that includes Legacy Forms (form controls available with previous versions of Word, such as text box, check box, or drop-form fields) and ActiveX controls

Word 2010 Content Controls

Design Mode

Displays the document in Design Mode so that you can arrange and edit content controls in the document

Word 2010 Content Controls

Properties

Opens a dialog box containing options you can change for the selected control

Word 2010 Content Controls

Group

Groups the items within a selected region of a form

Tip

It’s helpful to have an idea of the types of content controls you want to add to your document before you add them. You might want to sketch out the document on a piece of paper or use an existing document as a guide.

Control Types in Word 2010

You can use the content controls in Word 2010 to gather and connect the information you need to make your business processes run smoothly. In addition, they offer people reading your document specific and easy-to-understand ways to interact with the items on your page. Word 2010 includes a number of different content controls, each of which collects a different type of information. The sections that follow provide a closer look at the different types of content controls.

Rich Text Control

With the Rich Text control, you can add an item to your document that the user can then format as real text. For example, suppose that you want users to have the ability to change the format of the text they enter in a control. When you add a Rich Text control to the form, the Mini Toolbar appears whenever the user enters text in the control and then selects it (see Figure 27-4).

A Rich Text control lets users format text after they enter it.

Figure 27-4. A Rich Text control lets users format text after they enter it.

Rich Text controls also accept larger amounts of text (multiple paragraphs) and can include tables and graphics. When you need to provide the flexibility of gathering information in a variety of forms and formats, Rich Text controls will give you what you need.

Plain Text Control

The Plain Text control command inserts a simple Text control at the cursor position. When might you want to use a Text control? This control is useful for all kinds of things: you can record comments, names, addresses, volunteer projects, campaigns, staff member names, and more. Text controls can accept a minimal amount of formatting; basically, any text your users need to enter that doesn’t require special formatting capabilities can be entered in a Text control. In Figure 27-5, the Contact field is a Text control.

With Text controls, users can enter plain text—no formatting required.

Figure 27-5. With Text controls, users can enter plain text—no formatting required.

Picture Content Control

A Picture control comes in handy when you want to add special images in a document. For example, the team information document includes picture controls so each team member’s photo can be added (see Figure 27-6).

The Picture content control gives users the option of adding images directly into the document.

Figure 27-6. The Picture content control gives users the option of adding images directly into the document.

Combo Box Control

Use a Combo Box control when you want to give users a range of choices from which they can select, while also giving them the option of entering a new item not represented on the list. For example, in the control shown in Figure 27-7, the primary task list shows the various tasks you can assign to a team member. Or, if you don’t see the task you want to select, you can click in the text box and type the task that you want to include.

Combo boxes provide users with a list from which they can choose, or they can also enter their own information.

Figure 27-7. Combo boxes provide users with a list from which they can choose, or they can also enter their own information.

Drop-Down List

Use a Drop-Down List control to create a list from which users can select an answer. Unlike the combo box, which gives you the option of allowing users to add their own entries, a drop-down list constrains users to only the answers you provide. The sample drop-down list in Figure 27-8 shows the managers available to the team. You can choose the manager you want to assign to each team member by clicking the appropriate name on the list.

A drop-down list provides users with a range of choices.

Figure 27-8. A drop-down list provides users with a range of choices.

Date Picker

The Date Picker control makes it easy for you to select the date relevant to the information you are entering. You can type a date in the text box or click the arrow to display a calendar that shows the current month (see Figure 27-9). You can display different months by clicking the left or right arrows in the Date Picker title bar. To select a date, simply click the day you want (or click Today to enter the current date).

The Date Picker control displays a calendar you can use to insert a date in the document.

Figure 27-9. The Date Picker control displays a calendar you can use to insert a date in the document.

Tip

The Date Picker doesn’t provide a way to show a range of dates, so if you want to include information about a span of time (to record the amount of time spent on a volunteer assignment, for example), create Start Date and End Date fields to record the beginning and the completion dates of the project.

Adding a Control

Now that you know what to expect from the various controls, you can begin adding them to your document. When you are ready to add a control, the process is simple, and no matter which type of control you are adding, the process is the same. Follow these steps:

  1. Click at the point in the document where you want to add the Content Control.

  2. On the Developer tab, click the control in the Controls group that you want to add to your form.

    For example, to add a Combo Box control to your form, click the Combo Box control.

  3. Word adds a Combo Box control to your form and inserts the text, Choose an item.

When the user clicks the arrow to the right of the prompt text, a drop-down list appears, but only the prompt text appears in the list. You add the items for the list by working with the control’s properties (which is the subject of the next section).

Changing Content Control Properties

After you’ve created a Content Control, you can tailor it to include the information you want users to enter. You will change control properties when you want to do one of the following:

  • Add a title to the field

  • Specify a tag so that you can locate the field easily

  • Choose a formatting style to apply to the displayed text

  • Control whether the field contents can be edited or not

  • Choose the format of the content

  • Select a locale and calendar type (Date Picker control only)

  • Determine how to store the date if the control has an XML mapping (Date Picker control only)

  • Indicate whether you want Word to allow multiple paragraphs (Text field only)

  • Add and arrange items in a list (Combo Box and Drop-Down List only)

  • Assign Document Building Block Properties, such as a gallery and category, to populate a list of choices (Building Block Gallery control only)

To display the properties for a control you’ve added to the document, click the control, and then click Properties in the Controls group (or, in some cases, right-click the control). The Content Control Properties dialog box appears, in which you can customize the settings for that particular control.

Each control type has its own set of options. For example, when you add a Combo Box content control and then choose Properties, you see the dialog box shown in Figure 27-10. When you display the properties for a Rich Text content control, the dialog box shown in Figure 27-11 is displayed.

When you add a Combo Box content control, you add list items in the Properties dialog box.

Figure 27-10. When you add a Combo Box content control, you add list items in the Properties dialog box.

The Content Control Properties dialog box for a Rich Text content control.

Figure 27-11. The Content Control Properties dialog box for a Rich Text content control.

Adding Titles and Tags

Adding a title to a control on your form can help give users a little more information about the type of data you want them to enter. When you add a control title, the title appears on a tab above the control when the user clicks it.

To add a title to a control, select the control and click Properties in the Controls group. In the Content Control Properties dialog box, click in the Title text box and type the control title you want to use. Click OK to save the change.

You can also add tags in the Content Control Properties dialog box. When you add a tag, the control is enclosed in a set of tags that helps you locate, sort, and easily work with that data. Add a tag by clicking in the Tag box in the Content Control Properties dialog box. Type the tag name then click OK. By default, the tag is not visible on the form. To see the tags, click Design Mode in the Controls group. Figure 27-12 shows both the control title and tags displayed in Design Mode.

You can display the tags used to mark each Content Control by clicking Design Mode in the Controls group.

Figure 27-12. You can display the tags used to mark each Content Control by clicking Design Mode in the Controls group.

Tip

When a Content Control is mapped to a data store, the tags will appear orange in Design Mode. Content Controls that are not mapped will have blue tags in Design Mode.

Styling Your Control

You can control the way the text in your control looks in Word 2010 by setting style options. You can use an existing style for the control items or create a new style for the look of the text. The great thing about this is that you can automate the formats you use regularly in forms text. You can create a style you like and then choose it each time you create a control so that all your controls have a similar look.

To choose an existing style for your content control, follow these steps:

  1. Click the control you want to change.

  2. Click Properties in the Controls group on the Developer tab.

  3. Select the Use A Style To Format Contents check box. The Style selection becomes available.

  4. Click the Style arrow to display the available styles (see Figure 27-13).

    You can apply an existing style to document control text.

    Figure 27-13. You can apply an existing style to document control text.

  5. Click the style you want to use for the control text then click OK.

If you want to create your own style for the text users will see in the document, follow these steps:

  1. Click the control you want to change and display the Content Control Properties dialog box by clicking Properties in the Controls group.

  2. Select the Use A Style To Format Contents check box.

  3. Click the New Style button.

    The Create New Style From Formatting dialog box appears.

  4. Type a name for the style in the Name box, and then select a Style Type and Style Based On settings if necessary.

  5. Click the Formatting arrow then choose the font you want from the displayed list.

  6. Apply additional formatting settings, such as size, style, font color, or alignment, and more, using the controls in the Formatting area of the dialog box.

    The preview window shows you how the style will look in your document.

  7. Click OK to save the new style. Click OK a second time to apply the settings to your control and return to the document.

Note

For more information on styles, see Chapter 12.

Locking Controls

By default, no locking features are in effect for the content controls you create, meaning that for controls where editing is allowed (Rich Text controls and Combo Box controls), users can edit the control itself as well as the control’s content. Word offers you two different kinds of locking capability for the controls on your document. You can opt to lock the content control so that it cannot be deleted, or you can lock the contents so that they cannot be edited. When would you use these different options?

  • Select Content Control Cannot Be Deleted when you want to ensure that the user of your document will not be able to intentionally or unintentionally delete the document control.

  • Click Content Cannot Be Edited when you want to limit users from modifying the content displayed in the Content Control. For example, you might want to lock a text control to prohibit users from changing content that has already been added to the control.

You can also use the Contents Cannot Be Edited option to force a particular selection on a document. For example, suppose that you ordinarily allow users to order one of three versions of your annual report—PDF, Web, or print. For now, however, you’re out of your print reports, and you want to offer the PDF option only.

You can select the PDF option and then click the Contents Cannot Be Edited check box. This locks the selected item in place so that users cannot choose a different item in that particular control. When you print reports are back in stock, you can display the control’s properties and clear the Contents Cannot Be Edited check box in the Content Control Properties dialog box so that users once again have a range of choices.

Adding Content to Lists

This last setting in the Content Control Properties dialog box might be one you’ll want to use first. When you create a Combo Box control or a Drop-Down List control, the whole idea is to give document users a range of choices from which to choose. But when you initially create the control, only prompt text appears—which isn’t going to serve your purpose very well. To add the items to the lists, follow these steps:

  1. Select the Combo Box or Drop-Down List control to which you want to add list items.

  2. Display the Content Control Properties dialog box by clicking Properties in the Controls group.

  3. In the Drop-Down List Of Properties area, click Add.

    The Add Choice dialog box appears (see Figure 27-14).

    The Add Choice dialog box is where you add both a Display Name and a Value for your list items.

    Figure 27-14. The Add Choice dialog box is where you add both a Display Name and a Value for your list items.

  4. Type the text you want to appear in the list then click OK. The item is added to the list. Repeat Step 3 and this step until you’ve entered all the items you want to appear in the list.

  5. Arrange the items in the list the way you want them to appear in the control by using the Move Up and Move Down buttons in the Content Control Properties dialog box. Additionally, you can edit an item by selecting it in the list then clicking Modify. Or, you can delete an item by clicking it then choosing Remove.

  6. Click OK to save your changes.

Try out the list by clicking the arrow to the right of the control on the document. The list should appear in the order you specified.

Note

The Combo Box control enables users to add their own items into the text list. If a user chooses to take advantage of this feature, the latest added item is automatically displayed at the top of the list if the control is mapped to a data store.

Mapping Controls to XML

When you click Design Mode on the Developer tab, the tags that are displayed indicate the start and end of content controls and help you see what’s going on in your document, but they don’t automatically provide XML functionality for the data you are displaying or capturing. To map the data to the XML data store, follow these steps:

  1. Right-click the content control to display the Controls contextual menu.

  2. Point to Apply XML Element. A list of XML tags available in the current document appears.

    Note

    You must have an XML schema attached to the document before these tags will appear. To attach a schema, click Add-Ins in the Add-Ins group, click the XML Schema tab, click the Add Schema button, choose the schema you want to use in the Add Schema dialog box, click Open, and then OK.

  3. Click the XML element you want to apply to the content control.

Now the information displayed through or gathered by that content control is mapped directly to the XML data, and the latest information will be reflected by that control.

Using Content Controls

Designing a document with content controls is the first part of the story; using the controls is the second part. Working with a document that includes content controls is so simple it feels just like working with any traditional document (which is one of the main points of content controls). To use content controls in a document, follow these steps:

  1. On the File tab, choose New.

  2. Choose the document or template you want to use for the current document.

  3. Create, modify, and format your document normally.

  4. Each time you encounter a content control, click in the control and then type the requested information (or choose it from the displayed list).

  5. Save your document as you normally would.

Protecting Documents

When you’re working specifically with forms, the Protect Document tool is an important item on the Developer tab. You’ll use this type of protection when you want to safeguard all information in the document, allowing users to enter data only as you’ve specified in the individual content controls.

When you protect a form, you lock the controls in place so that no further changes can be made to formats or specifications. This also protects other items on the form—titles, help text, photos, and more. Of course, users will still to be able to use the lists as intended and enter text in text and legacy fields. To protect a document that includes content controls, follow these steps:

  1. Click the Restrict Editing command in the Protect group.

  2. Select the Allow Only This Type Of Editing In The Document check box.

  3. Click the list arrow then choose Filling In Forms (see Figure 27-15).

    You can protect the form but allow users to fill in form fields as needed.

    Figure 27-15. You can protect the form but allow users to fill in form fields as needed.

  4. Click the Yes, Start Enforcing Protection button to protect the form.

    The Start Enforcing Protection dialog box appears, offering you the chance to enter a password for the form. If you want to add a password, type it in both text boxes in the dialog box. If not, leave the text boxes blank.

  5. Click OK to put the protection settings in effect.

Adding Legacy Controls

Legacy controls are available in Word 2010, but unless you have a specific reason for using them (for example, one of your remote offices is still using a previous version of Word), the new content controls in Word 2010 are a better choice. You can add the following legacy controls in Word:

  • The Legacy Text control is a basic text input tool. When you add a Legacy Text control, Word 2010 inserts the {FORMTEXT} field at the current cursor position in the document.

    Note

    The field codes that Word inserts automatically can’t be modified. To change the settings for the inserted field type, double-click the field.

  • Use the Check Box control to create a list consisting of multiple check boxes. The {FORMCHECKBOX} field is inserted at the cursor position.

  • Use the Drop-Down control to provide a list of choices for the user in a legacy document. {FORMDROPDOWN} is added at the cursor position.

Tip

If you want to see which code Word is inserting in your document when you add legacy controls, simply press Alt+F9. The display changes to show the field codes. When you’re ready to return to the original display, press Alt+F9 again. Be sure to protect the form once again before you begin using it. Although this is not required for content controls, form fields will not work properly until the form is protected.

Adding ActiveX Controls

For special situations, you might want to use an ActiveX control to carry out actions when your user selects an item on your form. You might use an ActiveX control, for example, to run a macro that automates a task. ActiveX controls can add flexibility and power to your forms, but you need to be careful using them. Because of the type of objects they are, ActiveX controls can potentially access your local files and even be used to modify your registry. As such, you need to be careful to use ActiveX controls in a secure environment to ensure that hackers don’t find a doorway into your network through an unsecured ActiveX control.

ActiveX Controls and the Trust Center

The Microsoft Trust Center, which was introduced in Microsoft Office 2007, is one line of defense against those who might want to tamper with ActiveX controls. The Trust Center automatically reviews any document when you open it, looking for macros from sources not on your Trusted Publishers list, as well as ActiveX controls. For more information on the Trust Center and the Trusted Publishers list, see Chapter 20. To review the ActiveX settings currently in effect on your system, follow these steps:

  1. On the File tab, click Options.

  2. Click Trust Center then click the Trust Center Settings button.

  3. Choose ActiveX Settings.

    The range of settings for ActiveX controls is displayed in the Trust Center window.

  4. Review the settings and click the one that works best for your application.

  5. Click OK to save any changes.

Note

If you include ActiveX controls on your form and plan to deploy the form so that it can be used on other computers, be sure to include some explanatory text to inform readers how to change their ActiveX settings. This way you can ensure that the controls of your form will work properly on other systems.

Adding an ActiveX Control

To use ActiveX controls, you should be comfortable with Microsoft Visual Basic for Applications (VBA). To add an ActiveX control to your form, follow these steps:

  1. Open the template to which you want to add the control.

  2. Click the Restrict Editing tool then clear the check boxes in the Formatting And Editing options to unprotect the form.

  3. Place the insertion point where you want to add the control.

  4. Click the Legacy Tools command in the Controls group on the Developer tab.

  5. Click the ActiveX control button on the Legacy Tools gallery that you want in the document. Word adds the control to your form and changes the display to Design Mode.

Changing Control Properties

You can change the way an ActiveX control appears by modifying the control’s properties. To do so, display Design Mode, right-click the control to display the shortcut menu, and then choose Properties. The Properties dialog box appears, as shown in Figure 27-16.

Change the way a control looks by making changes in the Properties dialog box.

Figure 27-16. Change the way a control looks by making changes in the Properties dialog box.

Click the Categorized tab to see the various properties organized by category. If you want to make a change—for example, you might change the font—double-click the setting in the right column. When you double-click the font selection, for example, the Font dialog box appears, in which you can make the necessary changes then click OK.

Programming a Control

Although an in-depth discussion of using VBA to program an ActiveX control is beyond the scope of this book, you can easily access the code window for programming your control. To access the code window, follow these steps:

  1. Right-click the ActiveX control then click View Code.

    Word displays the Visual Basic Editor.

  2. Enter the code for the control’s event procedure.

  3. Click File then Close And Return To Microsoft Word to exit the editor and return to your document. Alternatively, you can simply press Alt+Q.

What’s Next?

This chapter introduced you to the content controls in Word 2010 and walked you through the simple process of adding content controls to your Word documents. The next chapter finishes up the book by taking a closer look at creating and working with macros.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset