Using ActiveX controls on Word documents

See Also

You can add controls to your documents to create interactive documents, such as online forms. For general information about adding and working with controls, see Using ActiveX controls on a document and Creating a custom dialog box.

Keep the following points in mind when you're working with controls on documents:

Writing event code for controls on documents is very similar to writing event code for controls on forms. The following SpinUp and SpinDown event procedures change the value of the TextBox control named "TextBox1" on the document where the SpinButton control named "SpinButton1" resides. The text box value is decreased by one when the user clicks the lower or left spin-button arrow and incremented by one when the user clicks the upper or right spin-button arrow.

Private Sub SpinButton1_SpinDown()
    Me.TextBox1.Value = Me.TextBox1.Value - 1
End Sub
Private Sub SpinButton1_SpinUp()
    Me.TextBox1.Value = Me.TextBox1.Value + 1
End Sub

The following Click event procedure switches to print view and sets the magnification to 100 percent for the document where the command button named "cmdChangeView" resides.

Private Sub cmdChangeView_Click()
    With Me.ActiveWindow.View
        .Type = wdPrintView
        .Zoom.Percentage = 100
    End With
End Sub