WindowSelectionChange Event

Microsoft Word Visual Basic

WindowSelectionChange Event

       

Occurs when the selection changes in the active document window.

Private Sub object_WindowSelectionChange(ByVal Sel As Selection)

object   An object of type Application declared with events in a class module. For more information about using events with the Application object, see Using Events with the Application Object.

Sel   The new selection.

Example

This example applies bold formatting to the new selection. This code must be placed in a class module, and an instance of the class must be correctly initialized in order to see this example work; see Using Events with the Application Object for directions on how to accomplish this.

Public WithEvents appWord as Word.Application

Private Sub appWord_WindowSelectionChange _
        (ByVal Sel As Selection)
    Sel.Font.Bold = True
End Sub