Share via


Document.SelectionChange-Ereignis

Wird ausgelöst, wenn sich die Auswahl im Dokumentfenster ändert.

Namespace:  Microsoft.Office.Tools.Word
Assemblys:   Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

Beispiele

Im folgenden Codebeispiel wird eine Meldung angezeigt, in der angegeben wird, dass sich die Auswahl ändert, sobald Sie die Auswahl im Dokument ändern.Dieses Beispiel bezieht sich auf ein Add-In auf Anwendungsebene.

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.");
}

.NET Framework-Sicherheit

Siehe auch

Referenz

Document Schnittstelle

Microsoft.Office.Tools.Word-Namespace