Lab 5: Importing Word Forms into InfoPath 2007
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
Learn how to convert your existing Microsoft Word documents into InfoPath forms to take advantage of the InfoPath form design and form-filling features. (5 printed pages)
Applies to:Microsoft Office InfoPath 2007, Microsoft Office Word
Download: InfoPath 2007 Sample: Training Labs.
Microsoft Office InfoPath 2007 has added several features to help users migrate existing Microsoft Office Word documents into InfoPath Form Templates. The Word document import feature does the following:
Imports the layout of the original document into an InfoPath view.
Creates an XML schema based on the layout of the document.
Inserts fields in appropriate locations.
Detects repeating tables.
Detects and converts existing Word Fields.
Infers controls such as rich text boxes, option buttons, and repeating tables from the structure of the form.
By selecting options before the import process, users can tune the converter to correctly recognize fields depending on conventions used in the original file.
After the import is completed, users can find out what items did not import correctly by using the Design Checker task pane, and they can take actions to correct them.
A user can modify the form by performing one-click conversions, such as converting a static table to a dynamic repeating table and converting a group of check boxes to a group of option buttons.
In this lab, you will learn how to perform the following tasks:
Start designing an InfoPath form template by importing an existing Word document.
Use the Design Checker task pane to discover and correct issues with the imported template.
Convert a static table to a dynamic repeating table.
Create a custom footer with fields bound to the XML in your form.
Contoso Corporation has been using an expense report form for several years. It was originally created in Word. To reduce the cost of form processing, the IT Department at Contoso wants to move to InfoPath 2007, so that the form data can be directly submitted as XML to the accounting system. You have been asked to create an InfoPath form template based on the existing Word document.
Importing a Word Document
For this exercise, you will use an example Word document that is included in the InfoPath 2007 Sample: Training Labs download to illustrate how the Word import feature works.
To import a Microsoft Office Word document
Open the Expense Report.doc, located at C:\2007 Office System Developer Resources\Code Samples\InfoPath2007SampleTrainingLabs, and examine the form.
The form contains the following elements:
A small table at the top that contains form field controls for the four input fields and a group of check boxes.
A table that contains five fields for entering expense details.
A lined section for entering notes.
A signature line.
A table at the bottom of the form for a number of approvers to sign.
InfoPath cannot import password-protected Word documents. Remove the password before importing the document into InfoPath.
In the Getting Started dialog box, click Import a Form.
In the Import Wizard, select InfoPath importer for Word Documents, and then click Next.
Click Browse, navigate to Expense Report.doc, select the file, and click Open.
In the Import Options dialog box, click Layout and form fields (custom conversion).
In the Convert To Text Box section, clear the Empty space after colons check box, and select the Empty table cells check box, as shown in Figure 1.
Click OK, and then click Finish.
Note the comments in the final screen of the Import Wizard, and click OK to open the form in the InfoPath designer.
Click File, and then click Save to save the form template.
Select a location, and then click Save.
InfoPath has imported the overall layout of the form, and has inserted text boxes at logical locations in the form. The lined area for notes has been replaced with a rich text field, and the expense details section has been replaced by a repeating table.
The Expense Details section is displayed with the same number of default rows that appeared in the original Word form.
Close the Preview window.
Reviewing, Correcting, and Updating the Imported Form
The Expense Report form contains some elements that cannot be imported correctly. In this section, use the Design Checker task pane to find items that did not import correctly and fix them.
The Approvers table at the bottom of the Expense Report form looks the same as it did in Word. However, the table was not imported as a repeating table because of the numbers in the first column. You will convert this table to a repeating table, so that additional approvers can be added or removed when the form is completed.
InfoPath correctly imported the check boxes from the original Word form. However, a user can select more than one check box at a time. You will change the list of divisions so that only one division can be selected by converting the check boxes to a group of option buttons.
You will also add a custom footer to your form, which will appear on every page. You will add the Name field and Date field from the form to the footer, so that when the form is printed, these fields are displayed at the bottom of every page.
To use the Design Checker to fix problems
Review the Import warnings in the Design Checker task pane, as shown in Figure 2.
The first two warnings refer to the two parts of the Contoso logo from the original document. Because InfoPath cannot represent a Word drawing, the drawing was replaced with a placeholder control. The star and the word "Contoso" were floating objects in Word, so InfoPath has inserted them into the layout at the best approximation of their original positions.
Delete the placeholder controls.
Save the form.
Unlike other warnings displayed in the Design Checker task pane, import warnings do not disappear after the form is corrected.
To change the static Approvers table to a repeating table
Scroll to the bottom and right-click inside the Approvers table.
Click Change to, and then select Repeating Table.
In the Number of rows to keep as a table header box, type 1 as shown in Figure 3.
Delete the number 1 in the first column.
At the top of the Design Checker task pane, click the down-arrow by the title of the pane, and select Controls to display the Controls task pane.
In the Controls task pane, drag a Text Box control into the first column of the Approvers table.
Save the form.
To change the Division check boxes to an option button group
Scroll to the top of the form.
Click the first check box to select it.
Hold down the SHIFT key and click the other two check boxes so that all three check boxes are selected.
Right-click the selected group of check boxes, select Change to, and then click Option Button.
The three check boxes are replaced by an option button group that is bound to a single field, as shown in Figure 4.
Save the form.
To add a custom footer
On the View menu click Header and Footer.
In the box marked Print form with this footer, type Contoso Expense Report.
In the Insert Auto Text list, select Field.
Expand the tree in the Select a Field or Group dialog box to display the Date field, and select it.
After the field formatting codes that InfoPath inserted for the date, type " – " (a space followed by a dash and another space).
Repeat steps 4–7 to insert the Name field.
After the field formatting codes that InfoPath inserted for the name, type " – ".
In the Insert Auto Text list, select Current Page.
The Footer format should now look like Figure 5.
Click OK in all the dialog boxes and save the form.
Click Preview and fill in the Date and Name fields.
On the File menu of the preview window, click Print Preview and scroll to the bottom of each page to verify that the custom footer appears as expected.
In these exercises, you learned how to start building an InfoPath form template by importing an existing Microsoft Office Word document. You also learned how to use the Design Checker task pane to discover elements of the form template that did not import correctly, and how to fix those errors. You learned how to perform two one-click operations to create repeating tables from static tables and to change check boxes to option button groups. Finally, you added a custom page footer with fields bound to your XML data.
In a real-world version of this form, you might continue to enhance the design of the form by:
Adding a color theme and images to give the form some style.
Adding calculations to automatically compute totals.
Adding the ability to sign the form using Digital Signatures.
Using features such as Rules, User Roles, and Information Rights Management (IRM) to define permissions and workflow for your form.
Publishing the form to the server so that it can be filled out in a Web browser.
To learn how to use InfoPath e-mail forms to deploy, collect, and analyze information, see Lab 6: Using InfoPath 2007 E-mail Forms.
For more information about developing with InfoPath, see the following resources: