A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Thursday, June 25, 2009

Create a visual studio template for InfoPath

If your jobs is to design InfoPath forms on a regular basis, it will be a good idea for you to create a visual studio template. Add basic code like validation functions, etc and basic layout with common fields and save it as a template. You can use this template to create new InfoPath projects. New projects will have all the basic fields, layout and common functions and it will save you lot of time. To create the template, create a new visual studio project for InfoPath. Design layout and add code. That's the easy part that you might have already known. Now, to create the template, go to "File" menu and select "Export Template".  If you don't see that option, you may have to reset the visual studio settings.
To do that, click cancel to close the "Export Wizard" and go to "Tools" menu and select "Import and Export Settings...".
You will be shown "Import and Export Settings Wizard". Select "Reset all settings" and click "Next".
Select option "No, just reset settings, overwriting my current settings" and click "Next".
From the list shown, select your appropriate environment. For example, if you are creating a template that has C# code and will be used for C# projects, select "Visual C# Development Settings". Likewise, for VB, you can select the VB development settings. Click "Finish"
Now go to "File" menu again and select "Export Template" option. If it still doesn't work, close and re-open visual studio.
Select "Project Template" and click "Next". If your solution has more than 1 project. The drop down at the bottom will show all the projects that are part of the solution and you will have to select one.
On the next screen, you can select icon, template name, template description, etc. Choose the output location and click "Finish".
The wizard will create a zip file that will contain all the necessary files required to create a new project.
Copy this zip file to the following folder on your development machine:
C:Documents and Settings[Current User]My DocumentsVisual Studio 2005TemplatesProjectTemplatesVisual C#
If it's a VB template, copy it to the "Visual Basic" folder.
Now, open visual studio, and in new project wizard, select project type "Visual C#" (OR Visual Basic if you created a VB template). The new template will appear under "My Templates". Select the template, change it's name and location and click "OK" to create the project.