Have you ever created an InfoPath form to later discover that you have to write code in order to accomplish something you need?
If so, you have one of two options:
You can use VSTA to add managed code to your form. It is included in the Office package, but it is turn off by default. You must go the Add/Remove Programs and customize Office to install it.
— OR —
You can use VSTO to add managed code to your form which is what this blog entry is about.
When you create an InfoPath Form Template using Visual Studio 2005, you start with the Design a Form dialog. On the left you’ll see:
Choosing one of these options will allow you to create a project using an existing form template. For example, if you wanted to use a form template from a SharePoint site, you would choose the second option. You can also choose the last option to import an Excel workbook or a Word document as your form template.
If you’ve selected an existing form template, you will get a message:
If you’ve selected a form template that already had code behind it, the existing code will be removed from the new form template as well.
VSTO will now create a project based on the form you’ve selected and you’re ready to add code!
Software Development Engineer