You receive a “Visual Studio must be used to add business logic to this form template” error message when you close the Form Options dialog box in InfoPath

When you close the Form Options dialog box in Microsoft Office InfoPath 2007 or in Microsoft Office InfoPath 2003, you receive the following error message:

Visual Studio must be used to add business logic to this form template. Please close this form template and open the Visual Studio project for it.

Note If you make changes before you close the Form Options dialog box, the changes are successfully saved even though you receive this error message.

CAUSE

This problem occurs when you create an InfoPath Form Template project in Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET 2003 and you click to select the Save using custom code check box in the Forms Options dialog box. When you select this check box, Visual Studio 2005 or Visual Studio .NET 2003 adds the OnSaveRequest event handler code to the project. Therefore, when you open the form template file (.xsn) outside Visual Studio 2005 or Visual Studio .NET 2003 in InfoPath, you receive the error message.

WORKAROUND

To work around this problem, make design changes to the form template file (.xsn) only when you work in the InfoPath Form Template project in Visual Studio 2005 or Visual Studio .NET 2003.

Steps to reproduce the behavior

To reproduce the behavior, follow these steps:

1. Start Visual Studio 2005 or Visual Studio .NET 2003.
2. On the File menu, click New, click Project, and then expand Microsoft Office InfoPath Projects.
3. Click Visual Basic Projects, click InfoPath Form Template, type <InfoPathProjectName> in the Name box, and then click OK.Note<InfoPathProjectName> is the name for your InfoPath Form Template project.
4. In the Microsoft Office Project Wizard, click Create a new form template, and then click Finish.
5. On the Tools menu, click Form Options, and then click the Open and Save tab.
6. Click to select the Save using custom code check box, and then click OK.
7. On the File menu, click Publish, and then click Next two times.
8. In the Form path and file name box, type <PathandFileName>, and then click Next.Note<PathandFileName> is the file name of the form template file (.xsn) and the path where you want to publish the file. For example, type c:\MyForm.xsn.
9. Click Finish, and then click Close.
10. On the File menu, click Exit to exit InfoPath.
11. On the File menu, click Exit to exit Visual Studio 2005 or Visual Studio .NET 2003.
12. Start InfoPath.
13. On the File menu, click Open, select the path and file name that you entered in step 8, and then click Open.
14. On the Tools menu, click Design This Form.
15. On the Tools menu, click Form Options, and then click OK.

Note After you click OK in the Form Options dialog box, you receive the error message that is mentioned in the “Symptoms” section.

——————————————–

Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

 


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image