Adding ActiveX Controls

 < Day Day Up > 



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 template to which you want to add the control.

  2. Click the Protect Form button 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 choosing 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, as shown in Figure 31-18.

    click to expand
    Figure 31-18: 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 an ActiveX control appears by modifying the control's properties. Right-click the control to display the shortcut menu, and then choose Properties. The Properties dialog box appears, as shown in Figure 31-19.

click to expand
Figure 31-19: 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 then click OK.

Programming a Control

Although an indepth discussion of using VBA to program an ActiveX 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 shown in Figure 31-20.

    click to expand
    Figure 31-20: When you click View Code, the Visual Basic Editor opens so that you can enter the script for the control.

  3. Enter the script for your Visual Basic program.

  4. Click File, Close And Return To Microsoft Word to exit the editor and return to your form. Alternatively, you can simply press Alt+Q.



 < Day Day Up > 



Microsoft Office Word 2003 Inside Out
Microsoft Office Word 2003 Inside Out (Bpg-Inside Out)
ISBN: 0735615152
EAN: 2147483647
Year: 2005
Pages: 373

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