Manually Creating Trusted Forms


If you don’t want to use the RegForm utility or if you want to use another installation method, you can always use the manual method to create a trusted form. To manually convert your form, open the form within InfoPath and select File | Extract Form Files to extract the files to a directory. Next, locate the manifest.xsf file and open it for editing using Notepad or the XML editor of your choice—you won’t be making too many changes to the file, so Notepad will be fine.

Within Notepad, select Edit | Find and locate the element marked xDocumentClass. To convert your form to be fully trusted, you need to add two attributes to this element, as follows (using the earlier example form and company names):

requireFullTrust="yes
name="urn:EmployeeInformation:Avantis"

Save this file back with its original name and extension and then open your XML template (template.xml) using the same method. You need to locate the tag marked mso-infoPathSolution and change the href reference within that tag to be the URN you specified before:

<?mso-infoPathSolution solutionVersion="1.0.0.2"  href="urn:EmployeeInformation:Avantis" productVersion="11.0.5329"  PIVersion="1.0.0.0" ?> 

Tip

You can also change the solutionVersion attribute to specify the version of the form you are converting. This is the equivalent of using the /v switch with the RegForm utility.

You need to repackage all the form files you extract back into an XSN file. You can use the MAKECAB utility that ships with Windows (which is also available for download from Microsoft.com), but, as described earlier, the easiest method is to use one of the Zip utilities that can generate CAB files (for example, ACDZip) and then change the file extension back to .xsn.

Installing Your Form

To install your form, you need to use either JScript or VBScript to register your form within InfoPath. The following is a JScript sample:

ExternalApplication = new ActiveXObject("InfoPath.ExternalApplication");
ExternalApplication.RegisterSolution("C:\\employee.xsn");
ExternalApplication.Quit();
ExternalApplication = null;

You could also create your own custom installation program using Visual Studio .NET or the tool of your choice (InstallShield, WiseInstall, and so forth) but you would need to run this snippet of code from within your setup program to properly register your form within InfoPath.

Removing Your Form

To remove a form from InfoPath, you can use the same snippet of script—only this time, instead of registering your form, you would be unregistering the form:

ExternalApplication = new ActiveXObject("InfoPath.ExternalApplication");
ExternalApplication.UnregisterSolution("urn:EmployeeInformation:Avantis");
ExternalApplication.Quit();
ExternalApplication = null;

Keep in mind that this removes the form from the Custom Installed Forms listing, but it does not actually delete the underlying form file. You would need to add your own code if you wanted to delete the form field as well.




How to Do Everything with Microsoft Office InfoPath 2003
How to Do Everything with Microsoft Office InfoPath 2003 (How to Do Everything)
ISBN: 0072231270
EAN: 2147483647
Year: 2006
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net