Word 2007[c] The Missing Manual

14.2. Creating a Computer Form

Printed forms are fine, but they have a drawback: Sooner or later, someone has to manually take the information from the form and transfer it to address labels or a database to use it. This process is time-consuming and subject to error. If your subscribers in the example above filled out a computer form, then you wouldn't have to retype the information to use it.

You can email your form to subscribers and have them fill it out in Word, but the problem with that is obvious. Anybody with Word can also edit your form, even deleting important information and returning you something useless. (Or worse , what if they change your subscription rates?) You can solve this problem by using Word's content controls.

With content controls, you can lock up your form so bumbling or ill-intentioned folks can't change it, but they can type the information you need. You can create customized and clearly labeled text boxes and drop-down menus to make it easy for people to fill in just the information you're looking for. Content controls do other useful things, too, especially when it comes to using the information you collect. (Each content control has a name that other programs can use to extract information from your form.)

14.2.1. Understanding Content Controls

Microsoft provides several different types of content controls that you can plug into your documentseach designed to collect information in different ways.

Here's a description of the different content controls you can insert into your documents:

  • Rich Text . Text boxes that hold a paragraph of formatted text. Great for areas where people need to fill in information. For example, use a text box for the Name field in a form. The main advantage of the Rich Text control over the plain text content control (mentioned next ) is that the typist can apply different formatting to the text within the text box. For example, you can type "The Missing Manual."

  • Text . For most forms, you should use the plain Text box. Use the Rich Text content control when the content needs elaborate formatting. You can format the words in a Text content control, but all the words are formatted the same. One major advantage of plain text boxes is that they can hold more than one paragraph. Rich Text content controls permit only one paragraph.

  • Picture . A content control that holds pictures, which can be anything from a photo to a chart to a company logo. Suppose you are creating an employee form with contact information for each employee in your company. With the Picture control, you can include a photo as well.

  • Combo Box . Shows a list of options and includes a text box for entries not on the list. Use a combo box to provide suggested options and still permit someone to enter their own information.

  • Drop-Down List . This content control lets you show your readers a list of options, just like those real-live drop-down menus on Web sites and computer programs. Drop-down lists limit the options someone can choose from. For example, you give people two choices: either yes or no. Or you give them a choice of 50 states. Drop-down menus also help eliminate incorrect or misspelled entries.

  • Date Picker . A calendar tool that lets your readers easily enter a date in a format that Word understands, without typos.

  • Building Block Gallery . Building blocks are predesigned, preformatted chunks of text, pictures, and other content that people can insert into documents.

  • Legacy Tools . These are controls and tools that were used in previous versions of Word. They don't have the same capabilities for sharing information as Word's new content controls, so unless you need to edit a form developed in an older version of Word, avoid the legacy controls.

14.2.2. Displaying the Developer Tab

When you create a computer form for other people to use, you graduate from the ranks of a mere Word worker bee to a Word developer. But don't worryyou don't have to don a propeller beanie yet. Your first step on the developer path doesn't involve learning a programming language or delving into your PC's innards. Instead, you're going to learn how to make Word do more of the work for you. To do so, you use ribbon menus and buttons just like the ones you've been using all along.

But first, you have to make those tools appear on the ribbonby adding the Developer tab. This tab has the tools for inserting content controls into your documents. The Developer tab also lets you record macros, edit Visual Basic code, and work with XML documents (as described in the next chapter).

Since most people rarely use these tools, you don't see the Developer tab when you first install Word. Here's how to bring it out of hiding:

  1. Choose Office button Word Options .

    You can also use the shortcut Alt+F, I to open the Word Options box. You can locate several buttons on the left side of the box. You find the Developer tab settings in the Popular panel. (If it's not selected, then click the Popular button at the top of the list.)

  2. Near the top of the window, turn on the "Show Developer tab in the Ribbon" checkbox .

    Several checkboxes at the top of the window turn the described settings on and off.


    Tip: While you're here, take a look at the "User name" box near the bottom. Your name is probably in the box; if not, enter it now. Word uses the name in this box for the Author field in every document.

  3. Click OK to close the Word Options box .

    When you close Word Options, you see the new Developer tab on the ribbon (Figure 14-5). When you click the tab, you meet some geeky -looking tools in the following groups: Code, Controls, XML, Protect, and Templates.

Figure 14-5. Most of the tools you use for forms reside in the Developer tab's Controls group . The small icons to the right are the content controls used for forms. The Design Mode button is a toggle. In Design Mode, you can change the settings and properties of the content controls in your document. The Properties button opens the selected control's Properties dialog box (see Figure 14-7).

14.2.3. Adding Content Controls to Your Form

Earlier in this chapter you created a form destined for the printer. Subscribers fill in the blanks on paper and return the form to you physically. Then you use that information to sign them up for magazine subscriptions. In this section, you take the paper-based form and modify it to work as a computer-based form. You add content controls and protect the form, so subscribers can fill in the blanks but can't mess with the rest of it. The content controls also make it easy for a database or some other program to retrieve the information from the Word form.

In this tutorial, you insert content controls in each of the spots on the form that had blanks or checkboxestext boxes and drop-down lists, respectively. Finally, you use the Developer Protect settings to restrict the kinds of changes your potential subscribers can make to the document.

14.2.3.1. Adding text boxes to your form

Text boxes let your readers truly fill in the blanks with their own information. Or you can restrict what they can enter using the Protect settings, as you see later in this tutorial. But first, you must add the text box to your document using the Developer Controls tools.

To get started, open the postcard form you created in Section 14.1.1 (or create it now). Or make a form that pertains to one of your own projects. Then follow these steps:

  1. Click within the second row of the table (under the Name label), and then choose Developer Controls Text to insert a Text content control (Figure 14-6) .

    Two types of Text content controls are available: Rich Text controls that readers can format and plain text controls, which simply store the characters without formatting. Plain text controls take on the formatting of the paragraph. For this example, you just want to collect the raw information, so you use plain text controls throughout this example, since formatting isn't an important part of the job. Plain text almost makes it easier for other programs such as FileMaker and or CGI script to read the information.

    Figure 14-6. Content controls look like text boxes, with a tab that displays the control's title. Don't fret if the box appears to be too small for the content it will hold. Word's text controls automatically adjust to fit the text typed into them.

  2. With the content control still selected on the ribbon, choose Developer Controls Properties or press Alt+L, L .

    The control's Properties box opens (Figure 14-7).

  3. In the Title text box, type Name . In the Tag text box, type Subscriber .

    Often, you use the same word for the title (which is what you call the control) and the tag (which is what software programs call the control behind the scenes), but it's not a requirement.

  4. Turn on the "Content control cannot be deleted" checkbox but leave the other boxes turned off .

    When people use your form, they won't be able to inadvertently or purposely delete the control, but they will be able to type in new text.

    Figure 14-7. Using the Content Control Properties dialog box, you can change the appearance and the behavior of your form's text boxes, drop-down lists, and other controls. For example, you can choose whether controls allow multiple paragraphs and whether they can be changed or deleted. You can find different options for different types of controls, as described in much greater detail in Section 14.2.

  5. Similarly, in row four, insert a Text content control for the address line (Alt+L, E), and then set the properties (Alt+L, L) .

    For the address control, type Address into the Title and Tag text boxes. Turn on the "Content control cannot be deleted" and "Allow carriage returns (multiple paragraphs)" checkboxes. The latter option lets subscribers enter multiparagraph address lines. For example, they may want to include a company name or a suite number with their address.

In the same way, add content controls for the other address items in the form: City, State, and Zip code.

14.2.3.2. Adding drop-down lists to your form

Drop-down lists give your subscribers much less leeway. The only way they can enter information with a drop-down control is by choosing one of the items on the listor not. On the other hand, drop-down lists can make everyone's life easier by guiding your readers toward expected responses and eliminating the possibility of mistyped entries. Adding drop-down lists is just like adding text boxes, although the properties are, of course, different.


Tip: The properties for all of Word's content controls are described later in this chapter. To insert a different content control, like a date picker, follow the steps outlined here, and then flip to Section 14.3 to find out how to set the properties.

Like the previous tutorial, these steps assume you've already created the postcard form in Section 14.1.1.

  1. For each magazine and the Porsche sweepstakes, add a drop-down list (Alt+L, O) .

    Use the keyboard shortcut or Developer Controls Drop-Down List to insert the controls. At first, the newly inserted controls may bend your table out of shape. You can change that as you set the properties for the controls.

  2. Figure 14-8. When you create a drop-down menu, you define the items shown on the menu in the Content Control Properties box. This box contains two menu items: Yes and No. If Yes is selected, the content control stores the value 1. If No is selected, the control stores 0.

    Each display name can also have a value assigned to it. The value is the data computer programs use when they process the information collected by the form.

  3. In the box at the bottom of the Content Control Properties dialog box, click the Display Name "Choose an item," and then click the Modify button on the right .

    The Modify Choice box opens where you can change the Display Name and the Value.

  4. In the Display Name box, type Yes, and in the Value box, type the number 1. Click OK to close the box .

    When your subscribers say "Yes," they want to receive a magazine, the dropdown list records the information as the value 1. Since you're using a numerical value instead of just Yes or No, another program like a database can do cool things like add up how many magazines you've sold.

    Next, you need to add the No option to the drop-down list, and to do that you have to add another name to the Display Name list.

  5. Click the Add button to open the Add Choice box .

    Apart from the name, it looks identical to the Modify Choice box. In the Display Name box, type No , and in the Value box, type the number .

Repeat the steps to create Yes/No drop-down lists for the rest of the magazines and to enter the Porsche sweepstakes.

14.2.4. Protecting Your Computer-Based Form

When you create a form for others to use, you want them to fill in the blanks and provide information. You don't want them to delete the explanatory text or the content controls you've carefully placed in the form. You have different ways to protect a document, but the most common method is to lock the entire document so that the only thing people can do is provide information in the content controls.

Open the form you created in the previous two tutorials, or any Word document you want to protect before you distribute it, and then follow these steps:

  1. Choose Developer Protect Protect Document Restrict Formatting and Editing .

    The Restrict Formatting and Editing panel is divided into three numbered groups (Figure 14-9). In the first group, "Formatting restrictions," you limit the way other people can format your document. Leave this alone for now. The second group, "Editing restrictions," has a checkbox and a drop-down menu.

  2. Turn on the "Allow only this type of editing in the document" checkbox, and then choose "Filling in forms" from the drop-down menu .

    This setting makes it so people can type into text boxes and make selections from drop-down lists, but they can't, say, change the text or the structure of your document's table.

  3. In the third group, click the "Yes, Start Enforcing Protection" button to protect your document from changes .

    The Start Enforcing Protection box appears giving you the opportunity to password-protect your document. If you password-protect the document, only you or someone with the password can make changes to the document's protection settings. (Password protection doesn't prevent anyone from filling in the text boxes or using the other content controls.)

  4. A password isn't necessary for this example, so just click OK .

    The Restrict Formatting and Editing panel changes, showing one button that reads Stop Protection. You can use this button to stop protection at any time, so you can edit the form. For now, close the panel by clicking the X in the upper-right corner.

    Figure 14-9. The Restrict Formatting and Editing panel is divided into three parts . The first part lets you limit the way people can format your document. The second part lets you limit the way they can edit your document. The third part provides a button that lets you turn on the protection.

  5. Save the form as a template Office button Save As Word Template with the name form_subscription.dotx .

    By saving the form as a template, you can create new documents from the template, while leaving the original untouched. Templates are great for forms like this one. You can send each potential subscriber a new document to fill in, while your template remains bland and unchanged, ready for the next happy customer (Figure 14-10).

Figure 14-10. The completed computer-based form looks very similar to the paper-based subscription form. The difference is that it has content controls instead of blank boxes. The content controls help to manage the information you collected and give you a way to protect the form from unwanted changes.

POWER USERS' CLINIC

The InfoPath Alternative

If you're really serious about creating forms and working with information that's collected through forms, consider using Microsoft's InfoPath. One of the programs in the Office family, InfoPath is designed to create forms that collect data for use by databases and other programming tools. InfoPath can import and convert forms you've already created in Word or Excel. InfoPath is more powerful than Word because it has an extensive set of tools specifically for creating forms and checking the information people type in. For example, you can create a phone or Zip code content control that accepts only numbers .

You can create a date picker for people's date of birth that won't accept a date that's in the future. InfoPath is also setup to create forms that can collect information on Web pages or via email.

With Office 2007, Microsoft has shifted form creation responsibilities from the traditional Office programs onto the shoulders of InfoPath. Part of the reason for this shift may have to do with beefing up security and preventing people from using macros and controls to create malicious programs in Word, Outlook, and Excel.

Категории