How to open an InfoPath form and template that were moved or copied
Learn how you can avoid getting the error 'InfoPath cannot open the following file' by changing the contents of an InfoPath form that is linked to an InfoPath form template that was moved or copied to a different location or computer, so that you can open the InfoPath form again.
Your client had an InfoPath developer (someone you do not know) build an InfoPath form template and then publish it to a SharePoint server at your client’s site.
You do not have access to the SharePoint server where the form template was published, neither do you have direct access to the InfoPath form template the other person created and deployed to SharePoint.
To keep this scenario simple, let’s assume that the InfoPath developer did not add code to the InfoPath form template, so you’re dealing with a codeless InfoPath form template that was deployed to a SharePoint Form Library.
The InfoPath form template is not doing exactly what your client wants it to do, and the InfoPath developer has since left the company.
Now your client wants you to take a look at the form template and troubleshoot the form template and an XML file that was created using that form template, so your client sends you both the XML file and the original InfoPath form template that was deployed to SharePoint.
Now when you try to open the InfoPath form, you get the following error message:
InfoPath cannot open the following file: <InfoPath_Form_File_Name_And_Path>.
The following form template for the form cannot be found:
And when you try to open the InfoPath form template in Design mode, you get the following warning:
The form template was published to one location and has been saved or moved to a different location. To ensure that forms based on this template work correctly, publish the template again.
I’ve briefly touched upon how InfoPath form templates and InfoPath forms are related in the video tutorial Creating a simple InfoPath form template, but I’ll recap the essence of the story here.
An InfoPath form is an XML file that is based on an InfoPath form template (an XSN file). The XSN file contains all of the code and logic for an InfoPath form to be filled out through either the InfoPath client application or through a browser via SharePoint.
This means that the two always go together: To open an InfoPath form, you always have to have an InfoPath form template published somewhere. In essence, an InfoPath form is linked to its corresponding InfoPath form template.
But because an InfoPath form is just an XML file (so a text file), you can open it in Notepad to relink it to a different InfoPath form template that has the same structure and version as the original form template from which it was created.
So to fix the problem described above, you must do two things:
- Save the form template to your own computer (so that you can troubleshoot it) from within the InfoPath client application.
- Change the InfoPath form to point to the template you saved on your own computer.
Fixing InfoPath form templates that have been copied or moved
When an InfoPath form template has been moved or if you receive one that was saved or published to a different location than where it is currently located, all you have to do is open it, save it, and then republish it.
To correct an XSN (InfoPath form template) that has been moved or copied:
- In Windows File Explorer, right-click the InfoPath form template (XSN), and choose Design from the context menu that appears.
- When the InfoPath form template opens in InfoPath, click OK to close the warning message.
- On the File menu, click Save As, and save the InfoPath form template locally somewhere on disk.
The XSN should now open without any warnings, and you should be able to publish it.
Fixing forms that are linked to templates that have been moved
When an InfoPath form template that an InfoPath form is linked to is moved or cannot be found (so you get the error InfoPath cannot open the following file), you have to relink the InfoPath form to point to the InfoPath form template that has been published to a new location.
To relink an InfoPath form to an InfoPath form template that was moved and republished:
- Open the InfoPath form in Notepad.
- Change the href attribute in the mso-infoPathSolution processing instruction to point to the correct location for the newly published InfoPath form template.
Figure 1. InfoPath form processing instruction with the InfoPath form template the InfoPath form is linked to highlighted in yellow and the version number highlighted in green.
- If the version number of the newly published InfoPath form template differs from the original InfoPath form template of the InfoPath form, change the solutionVersion attribute to be the same as the newly published InfoPath form template.
You should now be able to open the InfoPath form without any warnings or errors.
Every time you save or publish an InfoPath form template, its version number is automatically increased.
Figure 2. InfoPath form template version number on the Form Options dialog box.
If you link an InfoPath form to an InfoPath form template that is of a newer version than the template the InfoPath form was originally created from, you’ll get the following warning message:
This form was created with a new version of the form template. InfoPath cannot find the new version. Do you want to open with the older version?
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.