Adding ActiveX Controls

3 4

For special situations, you might want to use an ActiveX control to carry out actions when your user selects an item on your form. You might use an ActiveX control, for example, to run a macro that automates a task. In order to use ActiveX controls, you should be comfortable with Microsoft Visual Basic for Applications (VBA) or Microsoft Script Editor. To add an ActiveX control to your form, follow these steps:

  1. Open the form template to which you want to add the control.
  2. Click Protect Form on the Forms toolbar to unprotect the form.
  3. Place the insertion point where you want to add the control.
  4. Display the Control Toolbox toolbar by clicking View, Toolbars, Control Toolbox.
  5. Click the ActiveX control button on the Control Toolbox toolbar that you want in the document. Word creates the control and displays the Exit Design Mode toolbar. (See Figure 36-17.)

figure 36-17. when you add an activex control to your form, word changes to design mode.

Figure 36-17. When you add an ActiveX control to your form, Word changes to Design Mode.

Note


Use the controls you create with the Control Toolbox for forms you want to make available in Word, not for Web-based forms. Many browsers don't recognize the controls you create with the Control Toolbox toolbar.

Changing Control Properties

You can change the way the control appears by modifying the control's properties. Right-click the control to display the shortcut menu; then choose Properties. The Properties dialog box appears, as Figure 36-18 shows.

figure 36-18. change the way a control looks by making changes in the properties dialog box.

Figure 36-18. Change the way a control looks by making changes in the Properties dialog box.

Click the Categorized tab to see the various properties organized by category. If you want to make a change—for example, you might change the Font—double-click the setting in the right column. When you double-click the font selection, the Font dialog box appears so that you can make the necessary changes and click OK.

Programming a Control

Although an in-depth discussion of using VBA to program a control is beyond the scope of this chapter, you can easily access the code window for scripting from your form. To access the code window, follow these steps:

  1. Click the control to select it. Unprotect the field if necessary by clicking Protect Form on the Forms toolbar.
  2. Click the View Code button on the Control Toolbox toolbar. Word displays the Visual Basic Editor, as Figure 36-19 shows.

    figure 36-19. when you click view code, the visual basic window opens so that you can enter the script for the control

    Figure 36-19. When you click View Code, the Visual Basic window opens so that you can enter the script for the control.

  3. Enter the script for your Visual Basic program.
  4. Click the Close box to exit the editor and return to your form.


Microsoft Word Version 2002 Inside Out
Microsoft Word Version 2002 Inside Out (Inside Out (Microsoft))
ISBN: 0735612781
EAN: 2147483647
Year: 2005
Pages: 337

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