Share via


Document.SelectionChange (Evento)

Se produce cuando la selección cambia en la ventana de documento.

Espacio de nombres:  Microsoft.Office.Tools.Word
Ensamblado:  Microsoft.Office.Tools.Word (en Microsoft.Office.Tools.Word.dll)

Sintaxis

'Declaración
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

Ejemplos

En el ejemplo de código siguiente se muestra un mensaje que indica que la selección ha cambiado cada vez que se cambia la selección dentro del documento. Se trata de un ejemplo para un complemento en el nivel de la aplicación.

Private Sub DocumentSelectionChange()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.SelectionChange, AddressOf ThisDocument_SelectionChange
End Sub

Private Sub ThisDocument_SelectionChange(ByVal sender As Object, ByVal e As Microsoft.Office. _
    Tools.Word.SelectionEventArgs)
    System.Windows.Forms.MessageBox.Show("The selection in the document has changed.")
End Sub
private void DocumentSelectionChange()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(ThisDocument_SelectionChange);
}

void ThisDocument_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    System.Windows.Forms.MessageBox.Show("The selection in the document has changed.");
}

Seguridad de .NET Framework

Vea también

Referencia

Document Interfaz

Microsoft.Office.Tools.Word (Espacio de nombres)