How to: Create a Managed Code Form Template Using the InfoPath 2003 Object Model

The steps for creating a form template that works with the InfoPath 2003-compatible object model vary depending on whether you are creating your form template by using Microsoft Office InfoPath 2007 with Microsoft Visual Studio Tools for Applications (VSTA) or by using Microsoft Visual Studio 2005 with Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, or Visual Studio 2008 with Visual Studio Tools for Office.

Important

In addition to the procedures below, you must also click Save As on the File menu, and then select InfoPath 2003 Form Template (*.xsn) in the Save as type box to save the form template to the InfoPath 2003-compatible file format. Also, to open InfoPath 2003-compatible form templates created with Office InfoPath 2007, all InfoPath 2003 users must have the .NET Framework 2.0 installed on their computers (not .NET Framework 1.1 as is the case with managed code form templates created with the one of the InfoPath 2003 Toolkits for Visual Studio).

To create an InfoPath 2003-compatible form template in InfoPath with VSTA

  1. Start InfoPath.

  2. Click Design a Form on the File menu, and then in the Design a Form dialog box, select the following items:

    • Click Form Template

    • Click the icon for the data source on which you want your form template based in the Based on list

    • Clear the Enable browser-compatible features only check box

  3. Click OK.

  4. On the Tools menu, click Form Options.

  5. In the Form Options dialog box, click Programming.

  6. Under Programming language, select either C# (InfoPath 2003 Compatible) or Visual Basic (InfoPath 2003 Compatible) from the Form template code language drop-down list.

  7. Click OK.

    Design your form template, and then add event handlers in VSTA, as described in How to: Add an Event Handler Using the InfoPath 2003 Object Model.

To set creating InfoPath 2003 Form Templates as the default in InfoPath with VSTA

  1. Start InfoPath.

  2. On the Tools menu, click Options, and then click the Design tab.

  3. In the Programming language when designing forms that run in InfoPath box, select either C# (InfoPath 2003 Compatible) or Visual Basic (InfoPath 2003 Compatible).

  4. In the Save InfoPath forms as box, select InfoPath 2003 Form Template.

  5. Click OK.

    When you create a new InfoPath form template without selecting the Enable browser compatible features only check box, it will now default to using the InfoPath 2003-compatible object model.

To create an InfoPath 2003-compatible form template in Visual Studio

  1. Start Visual Studio.

  2. On the File menu, point to New, and then click Project.

  3. To create a C# project, under Project types, expand the Visual C# folder, click Office (in Visual Studio 2008, then click 2007), and then click InfoPath Form Template.

    To create a Visual Basic project, expand the Other Languages folder, expand the Visual Basic folder, click Office (in Visual Studio 2008, then click 2007), and then click InfoPath Form Template.

  4. In the Design a Form dialog box, perform the following actions:

    • Click Form Template

    • Click the icon for the data source on which you want your form template based in the Based on list

    • Clear the Enable browser-compatible features only check box

  5. Click OK.

  6. On the Tools menu, click Form Options.

  7. In the Form Options dialog box, click Programming.

  8. Click Remove Code, and then click Yes.

  9. Under Programming language, select either C# (InfoPath 2003 Compatible) or Visual Basic (InfoPath 2003 Compatible) from the Form template code language drop-down list.

  10. Click OK.

    Design your form template, and then add event handlers in Visual Studio, as described in How to: Add an Event Handler Using the InfoPath 2003 Object Model.

To set creating InfoPath 2003 Form Templates as the default in Visual Studio

  1. On the Tools menu, click Options.

  2. In the Options dialog box, click Microsoft Office InfoPath.

  3. In the Save InfoPath forms as box, select InfoPath 2003 Form Template.

  4. Click OK.

    When you create a new InfoPath form template projects, it will now default to using the InfoPath 2003-compatible object model.

See Also

Tasks

Walkthrough: Creating and Debugging a Basic Form Template Using the InfoPath 2003 Object Model

Other Resources

Creating Managed Code Form Templates Using the InfoPath 2003 Object Model