Microsoft KB Archive/832512

= The CreateObject function or the ActiveXObject function may generate a script error in InfoPath =

Article ID: 832512

Article Last Modified on 1/30/2007

-

APPLIES TO


 * Microsoft Office InfoPath 2007
 * Microsoft Office InfoPath 2003, Service Pack 1 (SP1)
 * Microsoft Office InfoPath 2003

-





SYMPTOMS
You may use the Microsoft VBScript CreateObject function or the Microsoft JScript ActiveXObject function to create an instance of an ActiveX component. If you create the instance of an ActiveX component in a script module of a function call for a Microsoft Office InfoPath form, you may receive one of the following error messages.

Automation Server can't create object

ActiveX Component can't create object



CAUSE
InfoPath forms always run in the context of an Internet security zone. The Internet security zone defines the actions that the script in a form can perform and the actions that the script in a form cannot perform. Typically, this error occurs because the Internet security zone where the form runs does not permit ActiveX components to be created if the ActiveX components are not marked Safe for untrusted script or Safe for untrusted initialization. This means that the author of the control does not certify that the component cannot cause damage to your system if presented with malicious script or malicious data.

For more information about how security zones affect the level of access that forms have to the resources on your computer, click Microsoft Office InfoPath 2003 or Office InfoPath 2007 Help on the Help menu, type About security zones in the Search for box in the Assistance pane, and then click Start searching to view the topic.

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

216434 How Internet Explorer determines if ActiveX controls are safe



RESOLUTION
To work around this problem in your InfoPath form, use either of the following methods:
 * Make the form a fully-trusted URN-based form.
 * Add the URL of the server that hosts the InfoPath form to the list of trusted sites in Microsoft Internet Explorer.
 * Digitally sign a form template. (Apply for InfoPath)

Make the form a fully-trusted URN-based form
The fully-trusted URN-based form must be installed on your computer by using a custom install script or by using the Microsoft System Installer package. This permits ActiveX components to be created even if the ActiveX components are not marked Safe for untrusted script or Safe for untrusted initialization.

You can convert a standard form to a URN-based form manually. However, manual conversion is tedious and is prone to errors. You can also convert a standard form to a URN-based form by using the RegForm.exe tool that is the command-line form registration tool that is included with the InfoPath software development kit (SDK). The RegForm.exe tool makes the required changes to the form definition file and to the XML template file. The Regform.exe tool then repackages the files to an .xsn file and then creates a custom installation program for installing the modified form template.

For more information about how to download the InfoPath 2003 SDK, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=351f0616-93aa-4fe8-9238-d702f1bfbab4

The default installation location of the InfoPath 2003 SDK is C:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools.

To see the command line options, type the following command line in a Command window: regform /? Notice the use of the /U switch and the /T switch in the command line. The /U switch specifies the URN to use for the form template. The /T switch specifies that the form template is fully trusted. This sets the requireFullTrust attribute in the form definition (.xsf) file to Yes.

The following command line produces a .js file and a .bak file in the same folder as the template that you are converting: regform /U urn:MyForm:MyCompany /T Yes C:\MyForms\MyTrustedForm.xsn The .bak file is a copy of the original form template file before the URN-based changes. The .js file is a script file that you can use to install the URN-based form.

To run the .js script, type the following code at the command line, and then press ENTER: Cscript  For additional information about a URN-based form or about the RegForm.exe tool, see the &quot;Using the Form Registration Tool&quot; topic in the InfoPath 2003 SDK Help documentation.

For more information about InfoPath 2007 and the InfoPath 2007 SDK, visit the following Microsoft Web site:

http://office.microsoft.com/en-us/infopath/FX100647031033.aspx?CTT=96&Origin=CL100607051033

Add the URL of the server that hosts the InfoPath form to the list of trusted sites in Microsoft Internet Explorer
When you add the URL of the server that hosts the InfoPath form as a trusted site, you receive the following message when you run the code:

An ActiveX control on this page might be unsafe to interact with other parts of this page. Do you want to allow this interaction?

If you click Yes, the code runs. If you click No, you may receive the error messages that are mentioned in the &quot;Symptoms&quot; section, and the code will not run.

To add a site as a trusted site, follow these steps:
 * 1) Start Internet Explorer.
 * 2) On the Tools menu, click Internet Options.
 * 3) In the Internet Options dialog box, click the Security tab.
 * 4) On the Security tab, click Trusted sites.
 * 5) Click Sites.
 * 6) Add the URL of the server that hosts the InfoPath form to the Add this Web site to the zone text box.

For example, if the name of the server that hosts the InfoPath form is, the URL that you must add to the text box is http://.
 * 1) Click Add.

This adds the newly-entered site to the Web sites list box.
 * 1) Click OK two times.

This commits the change and then closes the dialog box.

Digitally sign a form template
This applies to InfoPath 2003 Service Pack 1. If you digitally sign a form template with a trusted certificate, you can set the security level for the form template to Full Trust. Full Trust means that the form can access files and settings on the user's computer or on a different domain. Additionally, you can deploy and update that form template by sending the form template and updated versions of the form template to others by using an e-mail program.

To digitally sign a form with a trusted certificate, follow these steps:
 * 1) In Design mode, click Form Options on the Tools menu.
 * 2) In the Form Options dialog box, click the Security tab in InfoPath 2003 or click to select the Security and Trust check box in InfoPath 2007.
 * 3) Under Form Signing in InfoPath 2003, click to select the Sign this form check box.

Under Form Template Signature in InfoPath 2007, click to select the Sign this form template check box.
 * 1) Click Select Certificate.
 * 2) In the Select Certificate dialog box, click the certificate that you want to digitally sign the form with.

Note If a certificate is not trusted on a user's computer, Microsoft Office InfoPath 2003 displays a security message and requires the user to enable trust for the certificate issuer before the user can open the form.

