Freigeben über


Template Parts 101

So, you’ve heard about this new InfoPath 2007 feature called template parts. You may have even found the option to design one in the Design a Form Template dialog. But what you can do with it and why you would want to bother.. well that’s just a big mystery. So, I’m here to help you out.

Template parts are simply mini form templates: you can add layout, controls, rules, data validation, conditional formatting and data connections. Once built, you can include template parts in other form templates so that you only have to build common components once. When you need to make changes, you change the template part and then update its version within the form templates using it. You don’t have to make the modification numerous times. Common scenarios for template part use include:

  • Company letterhead
  • Employee information (address, phone number)
  • Purchase order

How to build a template part

Template parts are built in the same way that form templates are built, though there is a slight difference in how you get started. Because there are some limitations in what you can put into a template part (see "What template parts don’t do" below), they are built in a separate mode from regular form templates. This allows you to be sure that whatever you put into the template part will function as intended. At the Design a Form Template dialog, select the Template Part radio button:

Note that you can also choose whether or not the template part will be used in browser-enabled forms. If you aren’t sure, err on the side of caution and select “Enable browser-compatible features only”. This will ensure that you can use the template part in both client-based and browser-compatible forms.

Click OK and you can now design your template part as you would any other form template. When you are finished, save the template part (you will end up with a file ending in .xtp) and send it out to whoever you would like to use it.

How to use a template part

To actually put a template part into a form, you must first install it on your machine. This sounds a whole lot scarier than it actually is. All you need to do is click on the “Add or Remove Custom Controls…” link at the bottom of the Controls task pane and follow the instructions that appear:

Once you’ve done this, the template part will show up in the Custom Controls area of the Controls task pane. You can now insert the template part into your form as you would any other control. Once your template part has been inserted, you can also make modifications to it that are specific to that form.

How to update a template part

When you make changes to a template part that is already in use, you must redistribute the template part. The people using it must then install the new version (see “How to use a template part” above) and update the ones in their forms. Once the new version is installed, template parts in the form will automatically notice that there is a newer version available. You can then right-click on the template part and select Update. If you have made any changes to the template part within the form itself, these changes will be overwritten by the update.

What template parts don’t do

Here are some of the things that you can’t do with template parts:

  • Script and managed code
  • ActiveX controls
  • Submit data connections
  • IRM
  • Multiple views

The more complete list is available on Office Online. The general pattern is that anything that would be a form-level property is not available in template parts.

I hope you will find template parts to be useful and a mite less mysterious than they were before.

Happy form designing,

Bojana Marjanovic
Program Manager

Comments

  • Anonymous
    March 14, 2007
    PingBack from http://import-parts.net/template-parts-101/

  • Anonymous
    August 08, 2007
    Recently had a comment asking for online resources for InfoPath 2007 Template Parts and only posted 2

  • Anonymous
    March 18, 2008
    I like it. Short and sharp. I immediately put the concept to use. Thanks Michael Lotter. Ed.

  • Anonymous
    May 30, 2011
    This does not reflect the funcionality of InfoPath 2010, but InfoPath 2007. Please, how do you update template parts on InfoPath 2010 ? this feature seems to be unavaliable.

  • Anonymous
    May 31, 2011
    Gustavo, To create a new template part in InfoPath 2010, select Template Part from the New template options in InfoPath Designer. To update an existing one, simply open the template part (*.xtp, *.xtp2) in InfoPath Designer.

  • Anonymous
    May 30, 2012
    Has anyone experienced when you update a template part, it then duplicates all of the fields and renames them with a "_1" or "_2" at the end? I can get this somewhat consistently, but it seems to be related to when I have added at least one new field to the source template part.