oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Getting Started with Microsoft InfoPath 2003

by Wei-Meng Lee, author of Windows XP Unwired

One of the things I have always been averse to doing is filling out forms. This is especially troublesome if you work in a big company where you have to fill out multiple forms just to purchase an item. Most of you have had this similar experience: first you have to fill out a physical form to get your superior's approval for an item, then you must fill out an online requisition order to procure the item. Wouldn't it be nice if you could simply fill out one form that would allow all other applications to use the data collected on that form?

Microsoft has realized this problem and presents its solution in InfoPath 2003, an application that comes with Microsoft Office 2003 Professional Edition. InfoPath 2003 allows you to build forms for data collection and then save them in the XML document format. With XML, different applications can then reuse the information without the need for users to enter the same data multiple times.

In this article, I will introduce you to the power of InfoPath 2003 and show you how you can build a simple form to start collecting data.

Examining the XML Schema

InfoPath 2003 provides several ways for you to define the types of data you want to collect:

  1. XML Schema or XML document
  2. Database
  3. Web services

For this article, I will illustrate the first method--using an XML Schema. Suppose I have the following XSD document:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="">
<xsd:element name="Magazines" type="MagazineType"/>
   <xsd:complexType name="MagazineType">
         <xsd:element name="Magazine" 
   <xsd:complexType name="MagazineDetails">
         <xsd:element name="Title" type="xsd:string"/>
         <xsd:element name="Publisher" type="xsd:string"/>
         <xsd:element name="Comments" type="xsd:string" 
                      minOccurs="0" maxOccurs="1"/>
      <xsd:attribute name="Price" type="xsd:float"/>

This XSD defines the structure of the information that I want to collect. In particular, I want to capture magazine information such as title, price, and publisher.

Windows XP Unwired

Related Reading

Windows XP Unwired
A Guide for Home, Office, and the Road
By Wei-Meng Lee

Building and Designing the Form

Using the XSD document, I want to build a form to collect information about the magazines that I have. So, let's launch InfoPath 2003 and go to File -> Design a Form.

You will see the Task Pane displayed on the right side of the window (see Figure 1):

Figure 1.
Figure 1. Designing a new form

You can create a new form from a Data source (such as from a schema, a database, or a Web service), and then either start a blank form, or extend a sample form (provided by InfoPath 2003). For this example, I want to create a new form from an XSD document, and so I select "New From Data Source".

In the Data Source Setup Wizard (see Figure 2), select the type of data source to which you are connecting. In my case, select XML Schema or XML data file. Click Next.

Figure 2.
Figure 2. Selecting the data source

Browse for the XML Schema and click Finish.

In the Task Pane, you will be able to see the element and attribute names as defined in the XSD (see Figure 3).

Figure 3.
Figure 3. Viewing the data source

To build the form for the user to fill in, click on Layout in the Task Pane and use the required layout controls.

First, let's add a "Table with Title" to our form (see Figure 4). I have also changed the shading and font color.

Figure 4. Click for larger view
Figure 4. Adding a Table with Title to our form (You can click on the screenshot to open a full-size view.)

Then, click on Data Source in the Task Pane, and drag the Magazine folder into the Table (see Figure 5):

Figure 5. Click for larger view
Figure 5. Adding a table to our form (You can click on the screenshot to open a full-size view.)

You will be prompted to select the kind of section you want to add. Select Repeating Table (see Figure 6):

Figure 6.
Figure 6. Choosing the Repeating Table

You should see the layout, as shown in Figure 7:

Figure 7.
Figure 7. The newly created form layout

You are now ready to publish the form.

Publishing the Form

To publish the form, go to File - > Publish.

The Publishing Wizard provides three ways to publish your form (see Figure 8):

Figure 8.
Figure 8. Choosing the way to publish a form

In my case, I chose to publish it to a shared folder, c:\Magazine.xsn.

To use the form, the user simply needs to double-click on the .xsn file (in Windows Explorer) and InfoPath will launch the form. (In an Intranet setting, it would be useful to publish the form to a Web server and point the user to the URL to download the form.)

You can enter multiple magazine information by clicking on the arrow and selecting Insert Magazine above/below to add new records (see Figure 9):

Figure 9.
Figure 9. Filling in the form

Once you've completed entering the data, you need to save the form. To save it, simply click on File - > Save. All the magazine information will be saved in an XML document.

You can use NotePad to view the XML document you've generated:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="" 
productVersion="11.0.5531" PIVersion="" 
href="file:///C:\Magazine.xsn" language="en-us" ?>
<?mso-application progid="InfoPath.Document"?>
   <Magazine Price="5.95">
      <Title>SQL Server magazine</Title>
   <Magazine Price="4.95">
      <Title>Web Techniques</Title>
      <Comments>Renamed to ...</Comments>
   <Magazine Price="5.00">
      <Title>Wireless and B</Title>
      <Publisher>Sys-Con Media</Publisher>

Note that the XML document has two additional PIs (Processing Instructions) to invoke InfoPath 2003 when it is double clicked.

Since the information is now saved as XML, other applications can then easily use the information in the document.

Printing the Form

Besides filling in the form and saving the data as XML, InfoPath 2003 also allows you to print the form. This is especially useful when you need to generate a hard copy of your form to sign. You can preview the form by going to File - > Print Preview (see Figure 10):

Figure 10. Click for larger view
Figure 10. Viewing the Print Preview (You can click on the screen shot to open a full-size view.)


InfoPath 2003 is a useful tool for collecting data, especially in organizations where there is a need to integrate several applications together. In this article, you have seen how InfoPath 2003 works and how to build a very simple form to collect data and save it as an XML document. If you have any questions, feel free to use the TalkBack section below to send them to me.

Wei-Meng Lee (Microsoft MVP) is a technologist and founder of Developer Learning Solutions, a technology company specializing in hands-on training on the latest Microsoft technologies.

Return to the Web Development DevCenter.