This documentation is archived and is not being maintained.

How to: Open or Convert a Form Template Created with the InfoPath Toolkit or Script

If you created an InfoPath 2003 managed code form template using one of the InfoPath 2003 Toolkits for Visual Studio and want to maintain compatibility with InfoPath 2003, you can continue to work on and further develop your form template project by opening it in Microsoft Office InfoPath 2007 and Microsoft Visual Studio Tools for Applications (VSTA), in Visual Studio 2005 with Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System installed, or in Visual Studio 2008 with Visual Studio Tools for Office.

Alternatively, you can migrate and upgrade the code in your InfoPath 2003 project to use the new .NET object model provided by the Microsoft.Office.InfoPath namespace. When doing so, all of your code will need to be re-written to use members of the Microsoft.Office.InfoPath namespace, but all of the code from your previous project is retained and surrounded by #if InfoPathManagedObjectModel and #endif (C#) or #If InfoPathManagedObject Model and #End If (Visual Basic) statements for your reference.

It is not possible to migrate and upgrade form templates with script using the steps for a form template created with one of the InfoPath Toolkits. To do that, you need to first save a copy of the script code from the form template's script file for reference purposes. You can then convert the form template to use the new InfoPath managed code object model and re-write your business logic in managed code.

The following procedures describe how to open a managed code form template created with the InfoPath Toolkit and retain compatibility with InfoPath 2003 or migrate and upgrade to the new InfoPath object model. The final procedure describes how to convert a form template that has business logic written in script.

Open a managed code form template created with the InfoPath Toolkit and retain compatibility with InfoPath 2003 using VSTA

  1. Open InfoPath, and then click Design a Form Template on the File menu.

  2. Under Open a form template, click On My Computer.

  3. Navigate to the project folder where the InfoPath Toolkit form template project is saved.

    By default, this will be a folder in C:\Documents and Settings\username\My Documents\Visual Studio Projects on the computer where the project was created. Alternatively, you can move the folder to the location where InfoPath stores VSTA projects, which by default is C:\Documents and Settings\username\My Documents\InfoPath Projects

  4. Click the file named manifest.xsf, and then click Open.

  5. On the Tools menu, point to Programming, and then click Microsoft Visual Studio Tools for Applications.

  6. The message "This form template must be saved before you can add Visual Basic or C# code to it" is displayed. Click OK to continue.

  7. Navigate to the location where you want to save the file, name the file, and then click Save.

  8. The message "This code was created with one of the InfoPath 2003 Toolkits for Microsoft Visual Studio. InfoPath needs to migrate the toolkit project to a new format" is displayed. Click OK to continue.

  9. Select the Visual Studio Solution (.sln) file for the project, and then click Open.

  10. The message "Your project has been migrated" is displayed when the migration process is complete. Click OK to continue.

  11. The message "The code in this form uses the InfoPath 2003 object model" is displayed with the prompt "Do you want to upgrade your code to use the Microsoft Office InfoPath object model?" Click No to retain compatibility with InfoPath 2003 and to continue working with the object model provided by the Microsoft.Office.Interop.InfoPath.SemiTrust namespace.

    For information on working with managed code form templates that are compatible with InfoPath 2003, see Developing Managed Code Form Templates Using the InfoPath 2003 Object Model.

Open a managed code form template created with the InfoPath Toolkit and retain compatibility with InfoPath 2003 using Visual Studio

  1. Open Visual Studio.

  2. On the File menu, click Open Project.

  3. Navigate to the project folder where the InfoPath Toolkit form template project is saved.

    By default this will be a folder in C:\Documents and Settings\username\My Documents\Visual Studio Projects on the computer where the project was created. Alternatively, you can move the folder to the location of your choosing.

  4. Click the solution file (.sln) for the project, and then click Open.

    At this point, you can continue to work on the form template project and retain compatibility with InfoPath 2003. For information on working with managed code form templates that are compatible with InfoPath 2003, see Developing Managed Code Form Templates Using the InfoPath 2003 Object Model.

Open a managed code form template created with the InfoPath Toolkit and upgrade it to use the new InfoPath object model using VSTA

  1. Open InfoPath, and then click Design a Form Template on the File menu.

  2. Under Open a form template, click On My Computer.

  3. Navigate to the project folder where the InfoPath Toolkit form template project is saved.

    By default this will be a folder in C:\Documents and Settings\username\My Documents\Visual Studio Projects on the computer where the project was created. Alternatively, you can move the folder to the location where InfoPath stores VSTA projects, which by default is C:\Documents and Settings\username\My Documents\InfoPath Projects

  4. Click the file named manifest.xsf, and then click Open.

  5. On the Tools menu, point to Programming, and then click Microsoft Visual Studio Tools for Applications.

  6. The message "This form template must be saved before you can add Visual Basic or C# code to it" is displayed. Click OK to continue.

  7. Navigate to the location where you want to save the file, name the file, and then click Save.

  8. The message "This code was created with one of the InfoPath 2003 Toolkits for Microsoft Visual Studio. InfoPath needs to migrate the toolkit project to a new format" is displayed. Click OK to continue.

  9. Select the Visual Studio Solution (.sln) file for the project, and then click Open.

  10. The message "Your project has been migrated" is displayed when the migration process is complete. Click OK to continue.

  11. The message "The code in this form uses the InfoPath 2003 object model" is displayed with the prompt "Do you want to upgrade your code to use the Microsoft Office InfoPath object model?" Click Yes to upgrade the form template to use the new InfoPath 2007 managed code object model provided by the Microsoft.Office.InfoPath namespace.

    Your form code is opened in the VSTA code editor with all of the code from your previous project surrounded by #if InfoPathManagedObjectModel and #endif (C#) or #If InfoPathManagedObjectModel and #End If (Visual Basic) statements for your reference. All of this code will need to be re-written to use members of the object model provided by the Microsoft.Office.InfoPath namespace.

    For information on working with managed code form templates that use the new InfoPath managed code object model, see Developing InfoPath Managed Code Form Templates.

Open a managed code form template created with the InfoPath Toolkit and upgrade it to use the new InfoPath object model using Visual Studio

  1. Open Visual Studio.

  2. On the File menu, click Open Project.

  3. Navigate to the project folder where the InfoPath Toolkit form template project is saved.

    By default, this will be a folder in C:\Documents and Settings\username\My Documents\Visual Studio Projects on the computer where the project was created. Alternatively, you can move the folder to the location of your choosing.

  4. Click the solution file (.sln) for the project, and then click Open.

  5. In Solution Explorer, expand InfoPath Form Template, and then open manifest.xsf

  6. On the Tools menu, click Form Options, and then click the Programming category.

  7. Under Programming language, click Upgrade OM.

  8. The message "The code in this form uses the InfoPath 2003 object model" is displayed with the prompt "Do you want to upgrade your code to use the Microsoft Office InfoPath object model?" Click Yes to upgrade the form template to use the new InfoPath 2007 managed code object model provided by the Microsoft.Office.InfoPath namespace.

    Your form code is opened in the Visual Studio code editor with all of the code from your previous project surrounded by #if InfoPathManagedObjectModel and #endif (C#) or #If InfoPathManagedObjectModel and #End If (Visual Basic) statements for your reference. All of this code will need to be re-written to use members of the object model provided by the Microsoft.Office.InfoPath namespace.

    For information on working with managed code form templates that use the new InfoPath managed code object model, see Developing InfoPath Managed Code Form Templates.

Convert a form template with business logic written in script and upgrade it to use the new InfoPath object model

  1. Open the form template in InfoPath design mode.

  2. On the Tools menu, point to Programming, and then click Microsoft Script Editor.

  3. On the Edit menu, click Select All, and then click Copy.

  4. Paste the contents of the script.js or script.vbs file into Notepad and save the file for future reference.

  5. Click Form Options on the Tools menu, and then click the Programming category.

  6. Under Programming language, click Remove Code, and then click Yes.

  7. In Form template code language, select either C# or Visual Basic, and then click OK.

    None of your script event handlers and code will be retained. You must recreate them using the script file that you saved in step 4 for reference. For information on working with managed code form templates that use the new InfoPath managed code object model, see Developing InfoPath Managed Code Form Templates.

Show: