Yesterday, I put together an InfoPath 2007-based demo of VSTA to demo on a laptop. The laptop already had the VS2005 SDK installed and VSTA (msiexec /i vsta_aide.msi VSTAINVS=1) Installing VSTA from the VS2005 SDK enables the laptop to run the ShapeApp sample from the VSTA SDK.
1. My first step was to install InfoPath 2007. This went without complaint or error.
Using ‘Custom’ setup, I was able to only installed InfoPath 2007, leaving the Office 2003 Suite intact
2. Next, I opened an InfoPath form in design mode and hit Alt + Shift + F12… and nothing happened!
This was unexpected, since I was closely following the MSDN article written by Paul Stubbs, Add-In Power: Let Users Customize Your Apps With Visual Studio Tools For Applications
" …InfoPath 2007 includes Visual Studio Tools for Applications, so you can create applications in Visual Basic or C# using the embedded Visual Studio Tools for Applications environment. Figure 4 shows what the development environment and code look like when you press Alt+Shift+F12 while in design mode."
However, further in the article, Paul wrote that one can open VSTA another way, so I tried that next:
"Press Shift+Alt+F12 or click Tools | Programming | Microsoft Visual Studio Tools for Applications to open the development environment."
But, I did not see Microsoft Visual Studio Tools for Applications in the Tools | Programming menu. Instead, I saw Microsoft Script Editor Alt+Shift+F11
Ned Friend gives some direction about this in his blog post:
More than one way to write code: Visual Studio and InfoPath (http://blogs.msdn.com/infopath/archive/2006/07/06/658026.aspx)
"…Note that both Microsoft Script Editor (MSE) and Visual Studio Tools for Applications (VSTA) come with InfoPath 2007 Beta, so you can open them from the Tools | Programming menu. If you don't see the one you want, change the language in Tools | Form Options. If it gives you an error that it's not installed, here's how to install them:
If you are going to install VSTA, make sure you have the pre-requisites first:
Microsoft Core XML Services 6.0
.Microsoft .NET Framework version 2.0
Go to Start > Control Panel > Add or Remove Programs
Select your Office installation and click Change
In the Office Setup wizard select to add features
Find Microsoft Script Editor (under Office Tools) and/or Visual Studio Tools for Applications (under InfoPath > .NET Programmability) and select Run from my computer
Finish the wizard…"
3. In Tools | Form Options | Programming, I changed the Programming language selection from Jscript, to C#. Now Microsoft Visual Studio Tools for Applications is in the menu! So I Alt + Shift + F12 to open the VSTA IDE...and got another error dialog (InfoPath cannot start VSTA…), Just as Ned had warned me.
4. So I assumed that I needed to go into Control Panel | Add or Remove Programs and enable VSTA in there. Sure enough! VSTA was listed as a component in the install tree for InfoPath but turned off by default. So I installed VSTA (You must have the Office Ultimate 2007).
5. After doing this, I got back on track with Paul Stubbs’ Add-In Power article -- saved, the form and opened the VSTA IDE:
"Pressing F5, or clicking Debug | Start Debugging, will compile the code and start debugging your InfoPath form in Preview mode."
But the new VSTA project did not build! The Adapter and Contract assemblies referenced in the project had mismatched versions (8.0 and 2.0).
6. The only way to fix this problem was to go back to the Control panel and uninstall VSTA (inside VS2005 SDK) and then delete the assembly:
C:\Program Files\Visual Studio 2005 SDK\2006.02\VisualStudioToolsForApplications\Assemblies\Microsoft.VisualStudio.Tools.Applications.Contract.dll.
After uninstalling the VS2005 SDK, and re-loading the sample form, InfoPath’s VSTA project builds and runs successfully and the rest of my demo creation went fine, just as outlined by Paul.