Lab 10: Creating and Inserting InfoPath 2007 Template Parts

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.

February 2007

**Applies to:**Microsoft Office InfoPath 2007

Learn how to create an InfoPath template part in InfoPath 2007, insert it into a form template, and then modify and update it as necessary. (5 printed pages)

Contents

  • Lab Objectives

  • Lab Setup and Requirements

  • Scenario

  • Exercises

  • Conclusion

  • Additional Resources

Lab Objectives

After completing this lab, you will be familiar with the following:

  • Creating a template part

  • Inserting a template part into a form

  • Updating a modified template part

Lab Setup and Requirements

To complete this lab you must have Microsoft Office InfoPath 2007.

Scenario

The IT department at Contoso Corporation has been asked to update a number of its paper forms into electronic format. The department has decided to use Microsoft Office InfoPath 2007. Because most of the sales paper forms contain the same header section, template parts can be used to design the header section one time, and then that header section can be inserted into each of the sales forms.

Exercises

Creating Template Parts

Because there are some features of InfoPath that are not available in template parts, they are created in a mode separate from regular form templates.

To create a template part

  1. Start InfoPath 2007.

  2. In the Getting Started dialog box, click Design a Form Template.

  3. In the Design a Form Template dialog box, click Template Part.

  4. In the Based on area, click Blank, and then click OK.

  5. Click Layout in the task pane, and in the Insert layout tables section, click Table with Title.

  6. In the form, click the Click to add a title placeholder text, and type Title Placeholder using italic font style.

  7. Click the Click to add form content placeholder text, and type Contoso Corporation in bold text.

  8. Move your cursor under the table containing the form title, and press ENTER.

  9. In the Layout task pane, click Custom Table.

  10. Use the dialog box to select a two row by three column table, and click OK.

    At this point your template part should look similar to Figure 1.

    Figure 1. Inserting a table into a form

    Insert a Table into a Form

  11. Type additional labels and add controls so that your template part looks similar to Figure 2.

    Figure 2. Adding labels and controls to a form

    Add Labels and Controls to a Form

  12. Double-click Region Drop-Down List Box, and enter Contoso’s business regions—New York, Los Angeles, and Washington D.C.—by clicking Add in the List box entries section of the Drop-Down List Box Properties dialog box.

  13. On the File menu, click Save, and name the template part Contoso Header.

  14. On the File menu, click Close.

Inserting Template Parts into Forms

The template part you created can be inserted into one or more form templates. You must first add the template part to the Controls task pane.

To create a new form template

  1. On the File menu, click Design a Form Template.

  2. In the Design a Form Template dialog box, click Form Template, click Blank, and then click OK.

Next, you will install the template part; that is, you will add it to the Controls task pane.

To install the template part, adding it to the Controls task pane

  1. Switch to the Controls task pane, and at the bottom, click Add or Remove Custom Controls.

  2. In the Add or Remove Custom Controls dialog box, click Add.

  3. Keep the default settings, and then click Next.

  4. Click Browse, navigate to the previously saved Contoso Header template part, and then click Open.

  5. Click Finish, click Close, and then click OK.

    The new template part is now ready to be inserted into the form.

To insert the template part into the form template

  1. Scroll down to the Custom area at the bottom of the Controls task pane.

  2. Drag the Contoso Header onto the form template.

To use the template part

  1. Select the Title Placeholder line, and replace it with Sales Visit Report.

  2. Remove the italic font style.

    Your form should now look similar to Figure 3.

    Figure 3. Customizing the template part in a new form

    Customize a Template Part

  3. On the File menu, click Save.

  4. Type Sales Visit Report as the name of the form template, and then click Save.

  5. On the File menu, click Close.

Modifying and Updating Existing Instances of a Template Part

Updating a template part requires three steps:

  1. Opening the template part.

  2. Making changes.

  3. Saving the template part.

Then you must send the updated template part to anyone who is using the original. After the updated template part is installed on each computer, the users are notified that an update is available.

To edit an existing template part

  1. On the File menu, click Design a Form Template.

  2. On the left side under Recent form templates, click Contoso Header.

  3. Edit the template part by modifying the layout and adding controls so that it looks similar to Figure 4.

    Hint: Insert another row, merge the cells, and insert a Rich Text Box for the comments.

    Figure 4. Updating a template part

    Update a Template Part

  4. On the File menu, click Save.

  5. On the File menu, click Close.

To update a template part in an existing form template

  1. On the File menu, click the Design a Form Template.

    If the Getting Started dialog box is open, click the Design a Form Template link.

  2. On the left side under Recent form templates, click Sales Visit Report.

    Now you must reinstall the template part.

  3. Remove the original part from the Controls task pane by using the Add or Remove Custom Controls dialog box. Then click Add to install the updated template part.

    After you reinstall the template part, the Contoso Header in the form has an information icon Information icon in the upper-right corner.

  4. Right-click the template part name, and then click More Details.

  5. Click Update, and then click OK.

    You will notice that the template part in the form has been updated.

Conclusion

In this lab, you learned how to create a simple template part, insert it into a form template, and then edit the template part and update the version in your form. You learned how to create template parts and customize them for specific uses. In addition, you learned how to manipulate those parts after they are inserted into a form template, and how to update them when necessary. When you modify the design, each form template will automatically detect that a template part has been updated and display a notification icon.

Contoso’s multiple sales forms are now completed much faster because the repetitive header section is created one time and reused in each form that requires that information.

In Lab 11: Integrating InfoPath 2007 Forms in Web Sites Using Visual Studio, you can learn how to create Web pages in Microsoft Visual Studio 2005 that include links that open InfoPath forms.

Additional Resources

For more information about developing with InfoPath, see the following resources: