This chapter is from the book

Getting Started

At this point in the book, you not only know how to design form templates that look nice but you can also take advantage of most of the basic (and some not so basic) features available when using InfoPath in design mode. Now you can create professional-looking forms in no time. However, over time, as you create more and more form templates, you may find that many of them are very similar or share a lot of the same constructs.

For example, several of your form templates may contain sections used to collect address information from the user. It would be pretty tedious to have to add the same address block to each of your form templates, especially if there is no difference in this data from one form template to another. You could simply copy the controls and layout from the view and paste them into another form template. This would work fine for the view aspects of the form. However, what about the data structure, rules, calculated default values, data validation, and data connection information that you may have added to your form template? How do you copy these settings from one form template to another? Using copy and paste, this just isn't possible.

There is another way to share different parts of a form template in multiple form templates. With InfoPath 2007, you can build custom components that can be reused in one or more of your form templates. This means that you can create your own components or reuse ones created by third-party software providers.

You can create reusable components in two ways. The first is to write ActiveX controls in C++, Visual Basic, C#, or any COM-aware programming language. Creating controls this way requires you to put on your developer hat and write quite a bit of code. Since this is an advanced topic, we'll talk about this in the advanced section of this book in Chapter 19.

Fortunately, there is a second way to create custom components in InfoPath, one that doesn't require you to write even one line of code. These custom components are called template parts. As their name implies, template parts are parts of a form template. More specifically, template parts group pieces of a form template into a component that can be reused in multiple form templates. These custom components, which include controls, data structure, and many of the design features you've learned about so far (such as rules and data validation), enable you to quickly and easily reuse common design features across as many form templates as you choose. Let's jump right in and see how easy it is to create one of these components.