Creating a basic Template Part in Microsoft Office InfoPath 2007 is a simple process. However the rewards that come along afterwards when you have a nice library of template parts is quite nice. In this post I will give a high level walkthrough of the steps it takes so you can see yourself how easy they are to create and hopefully recognize a few of the benefits of possibly a little work upfront.
Creating a Template Part in InfoPath 2007
Open InfoPath 2007 and select to Design a Form Template
You are given a choice to create either a complete form or a template part. Because the component you are going to create will be used in multiple forms, it makes sense to package it as a template part instead. In this example, I will create a template part for contact information since it is contained in probably half the forms I make. Even if some slight items change, using a template part will give me a good starting point.
By selecting template part, you are given a choice to create from a blank template or based on an XML document or schema. In this case we will select Blank.
You design your form by adding the appropriate layout tables and controls to the form. It is always a good idea to begin this step with a sketched out idea of what your form will look like on paper and the data the form will collect including any dependencies or connections identified.
Similar to a complete template, you can import data from other data sources such as SQL, web services or SharePoint. In this case, I have a list of provinces contained on a centrally available SharePoint site so I will utilize that. You never know when Canada could decide to recruit a new province or territory so its important to make it easy for this listing to stay up to date. OK So maybe in this case I just hate typing so it’s easier for me to grab this information from a central listing somewhere.
After all my labels and controls have been added, I am ready to save my template part.
When you save the template part you will notice it has its own unique file extension (xtp) rather than the xsn you would see if you were saving a complete form.
Now whenever I want to create a form that contains contact information, I can simply add my template part instead of recreating every single field manually. Who has time for manual recreation of common elements when there are Stanley Cup Finals or World Cup Soccer games to watch?
Below the controls listing on the task pane select the link to “Add or Remove Custom Controls…”
Select Template Part from the wizard screen…
Browse to the location of your template part. If you are working on a team, then it would be a good idea to store these in a central location so as to be a library for everyone to use.
And Voila you have a new custom control available to you in the task pane.
Just like any other control, click and drag it onto the form to make it appear.
Depending on the complexity of your template part, you can evaluate the benefit of using template parts by comparing the length of time it takes to click and drag versus the length of time it took you to add all the controls and set up your data connection, then multiply it by the number of times you would typically have to add those fields to a form.