Microsoft KB Archive/891160

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

Article ID: 891160

Article Last Modified on 1/30/2007

-

APPLIES TO


 * Microsoft Office InfoPath 2007
 * Microsoft Office InfoPath 2003, Service Pack 1 (SP1)

-





SYMPTOMS
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.



MORE INFORMATION
For more information about InfoPath development in Visual Studio, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/office/aa905519.aspx

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  in the Name box, and then click OK.

Note is the name for your InfoPath Form Template project.
 * 1) In the Microsoft Office Project Wizard, click Create a new form template, and then click Finish.
 * 2) On the Tools menu, click Form Options, and then click the Open and Save tab.
 * 3) Click to select the Save using custom code check box, and then click OK.
 * 4) On the File menu, click Publish, and then click Next two times.
 * 5) In the Form path and file name box, type , and then click Next.

Note 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.
 * 1) Click Finish, and then click Close.
 * 2) On the File menu, click Exit to exit InfoPath.
 * 3) On the File menu, click Exit to exit Visual Studio 2005 or Visual Studio .NET 2003.
 * 4) Start InfoPath.
 * 5) On the File menu, click Open, select the path and file name that you entered in step 8, and then click Open.
 * 6) On the Tools menu, click Design This Form.
 * 7) 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 &quot;Symptoms&quot; section.

Additional query words: VS2003 InfoPath 2003 VS.NET InfoPath 2007 IP2007

Keywords: kbprogramming kbdesign kbxml kberrmsg kbtshoot kbbug kbprb KB891160

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.