Udostępnij za pośrednictwem


Zdarzenie Document.SelectionChange

Występuje, gdy zaznaczenie w oknie dokumentu.

Przestrzeń nazw:  Microsoft.Office.Tools.Word
Zestawy:   Microsoft.Office.Tools.Word.v4.0.Utilities (w Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)

Składnia

'Deklaracja
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

Przykłady

Poniższy przykład kodu wyświetla komunikat informujący, że zmiany zaznaczenia przy każdej zmianie zaznaczenia w dokumencie.Ten przykład dotyczy dodatek programu poziomu aplikacji.

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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

Document Interfejs

Przestrzeń nazw Microsoft.Office.Tools.Word