Friday, April 7, 2017

Insert an ActiveX control

Insert an ActiveX control

Creating and distributing your own custom ActiveX control can save time and effort for other form template designers, in addition to providing functionality that is not available in Microsoft Office InfoPath. You can make Microsoft ActiveX controls available in design mode and then use those controls on the form templates that you create.

In this article

When to use an ActiveX control

The user experience

Compatibility considerations

Insert an ActiveX control on a form template

Security tips

When to use an ActiveX control

Typically, you use an ActiveX control when you want to include a user interface element on your form template that isn't available in InfoPath, such as a slider control that comes with Microsoft Windows.

Your organization can also create its own custom ActiveX controls for a specific business use. For example, a hospital can develop an ActiveX control that allows medical imagery to be displayed on a form. Or suppose your sales representatives have to keep track of the number of items sold in a given month. Updating a text box by typing can be cumbersome and can result in errors, considering that sales representatives have to increment by one many times over. A custom ActiveX control that self-increments with a mouse click reduces the time that is spent tracking this information and can help reduce errors.

Top of Page

The user experience

What the user sees on the form depends entirely on the type of ActiveX control that you use on your form template.

When you publish a form template that contains an ActiveX control, that control must be installed and registered on users' computers in order for users to open forms that are based on the form template. Some ActiveX controls, like those that are included with Microsoft Windows, may already be installed and registered on the users' computers. Other ActiveX controls, such as custom controls that you develop, may not be installed and registered. In this case, you must take measures to install and register the controls for your users.

If you plan to install your form template with a custom installation program, you can install and register the custom ActiveX control at the same time. Alternatively, you can specify an existing cabinet (.cab) file in the Add Custom Control Wizard that is used to install the control on users' computers.

When you use the Add Custom Control Wizard to make an ActiveX control available to your users, you must specify if you want to package an existing .cab file along with your form template. This .cab file allows the control to be installed and registered on your users' computers. If you choose to include a .cab file with your form template and your users do not already have the ActiveX control installed, InfoPath prompts them to install the control when they open a form based on your form template for the first time.

InfoPath automatically installs and registers the control for users if both of the following requirements are met:

  • The .cab file is signed with a digital certificate that creates a digital signature on the file.

  • The digital signature is from a form developer or other trusted publisher. If the .cab file is signed but the publisher is not yet trusted on the user's computer, InfoPath displays a security alert and requires the user to enable trust for the publisher.

Top of Page

Compatibility considerations

When you design a form template in InfoPath, you can choose to design a browser-compatible form template. When you design a browser-compatible form template, ActiveX controls are unavailable in the Controls task pane because they cannot be displayed in a Web browser.

In addition, ActiveX controls are not available in template parts.

Top of Page

Insert an ActiveX control on a form template

Before you can add an ActiveX control to your form template, you must make it available in the Controls task pane. InfoPath includes an Add Custom Control Wizard that guides you through the process of selecting the ActiveX control, including an installation .cab file with your form template, if necessary, and specifying the binding options and other properties for the ActiveX control.

Add an ActiveX control to the Controls task pane

If you develop your own ActiveX control for use in InfoPath, you must identify that control as both safe for initialization and safe for scripting before you can complete the following procedure.

  1. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  2. At the bottom of the Controls task pane, click Add or Remove Custom Controls.

  3. In the Add or Remove Custom Controls dialog box, click Add.

  4. On the first page of the Add Custom Control Wizard, click ActiveX Control, and then click Next.

  5. On the next page of the wizard, click the control that you want in the Select a control list, and then click Next.

    Note: The Select a control list shows the ActiveX controls that are currently registered on your computer, including the ActiveX controls that are included with Microsoft Windows. If you created your own custom ActiveX control, you must register it in order for it to appear in the Select a control list. If ActiveX controls are incompatible with InfoPath or are deemed unsafe, you won't be able to add them to InfoPath.

  6. On the next page of the wizard, do one of the following:

    • To include an installation .cab file with your form template, click Include a .cab file, specify the file that you want to use, and then click Next.

    • To install the ActiveX control by using a custom installation program or if the ActiveX control is already installed on your users' computers, click Don't include a .cab file, and then click Next.

  7. In the Binding property list, do one of the following:

    • To bind a property of the ActiveX control to a field in the data source, click an item.

      Note: If the ActiveX control includes a Value property, InfoPath automatically selects it, but you can choose to change it.

    • To leave the ActiveX control unbound, click (do not bind).

  8. Click Next.

  9. Depending on the type of ActiveX control that you chose to add, an Enable or Disable property list may appear. If this is the case, click a property, and then click Next.

    Note: If the control includes an Enabled property, InfoPath automatically selects it, but you can choose to change it.

  10. If you specified a binding property in step 7, specify the binding options that you want.

    How?

    In the Field or group type list, do one of the following:

    • To bind the ActiveX control to a field with a simple data type, click Field (element or attribute). This type of binding is used by simple ActiveX controls, such as the slider control that is included with Microsoft Windows. If you select this option, you must specify a default data type for the ActiveX control, as well as any additional data types to which the ActiveX control can be bound.

    • To bind the ActiveX control to a field with a custom data type, click Field (element with custom data type). This type of binding is used by ActiveX controls that function as editors for a specific type of content, such as an equation editor that edits MathML. If you select this option, you must also specify a namespace for the XML that will be edited.

    • To bind the ActiveX control to a field or group, regardless of its data type, click Field or Group (any data type). This type of binding is used by ActiveX controls that analyze information that is entered elsewhere into the same form, such as a graph or chart, or by ActiveX controls that manipulate XML data directly.

  11. Click Finish.

  12. Review the confirmation message, and then click Close to exit the wizard.

  13. In the Add or Remove Custom Controls dialog box, click OK.

After the ActiveX control appears in the Controls task pane, you can insert it onto your form template.

Insert an ActiveX control on a new, blank form template

When you insert a Microsoft ActiveX control onto your form template, InfoPath inserts a custom control that is bound to either a field or a group in the data source, depending on the options that you specified in the Add Custom Control Wizard.

Note: If other form template designers in your organization need to use the same ActiveX control on their form templates, and if that control is not already installed on their computers, you can create a custom setup program, such as a Microsoft Windows Installer Package (.msi) file. This custom setup program can quickly install and register the ActiveX control for the form template designers.

  1. On the form template, place the cursor where you want to insert the control.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Under Insert controls, click the name of the ActiveX control that you want to insert.

    Security Note: Use caution when you add ActiveX controls to your form template. ActiveX controls can be designed in such a way that their use could pose a security risk. We recommend that you use only controls from trusted sources.

  4. Any property pages that are specific to the ActiveX control will appear alongside the standard InfoPath property pages for ActiveX controls. To see these property pages, double-click the ActiveX control on the form template.

Insert an ActiveX control on a form template that is based on an existing data source

If you base the design of your form template on an existing Extensible Markup Language (XML) file, database, or Web service, InfoPath derives the fields and groups in the Data Source task pane from that existing data source. In this scenario, you can insert an ActiveX control by dragging a field from the Data Source task pane onto the form template or by inserting the ActiveX control from the Controls task pane instead, as described in the following procedure:

  1. On the form template, place the cursor where you want to insert the control.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Under Insert controls, click the name of the ActiveX control that you want to insert.

  4. In the Control Binding dialog box, select the field in which you want to store the control's data, and then click OK.

Top of Page

Security tips

When designing forms that include ActiveX controls, you should keep the following security issues in mind:

  • ActiveX controls that are used in InfoPath have restrictions that are stricter than those for ActiveX controls used in Windows Internet Explorer. For example, InfoPath requires that ActiveX controls be marked as both safe for scripting and safe for initialization. If you develop custom ActiveX controls for use in form templates, you must implement the IObjectSafety interface so that InfoPath recognizes that a particular control is marked safe for scripting and safe for initialization.

  • Use caution when you add ActiveX controls to your form template. ActiveX controls may be designed in such a way that their use could pose a security risk. We recommend that you use only controls from trusted sources.

  • ActiveX controls cannot be installed by or run on form templates that have a restricted level of trust (as specified in the Form Options dialog box in design mode).

  • For information about designing more secure ActiveX controls, visit the Microsoft Developer Network (MSDN) Web site.

Top of Page

No comments:

Post a Comment