Share via


Document.ActivateEvent-Ereignis

Wird ausgelöst, wenn das Dokument das aktive Fenster wird.

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 ActivateEvent As WindowEventHandler
event WindowEventHandler ActivateEvent

Hinweise

Das ActivateEvent-Ereignis wird nur dann ausgelöst, wenn Sie den Fokus innerhalb einer Anwendung verschieben.Wenn Sie den Fokus auf ein oder von einem Objekt in einer anderen Anwendung verschieben, wird das Ereignis nicht ausgelöst.

Beispiele

Im folgenden Codeausschnitt wird eine Meldung angezeigt, wenn das Dokument aktiviert wird.Dieses Beispiel bezieht sich auf ein Add-In auf Anwendungsebene.

Private Sub DocumentActivateEvent()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.ActivateEvent, AddressOf ThisDocument_ActivateEvent
End Sub

Private Sub ThisDocument_ActivateEvent(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
    System.Windows.Forms.MessageBox.Show("The document has been activated")
End Sub
private void DocumentActivateEvent()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.ActivateEvent += new Microsoft.Office.Tools.Word.WindowEventHandler(ThisDocument_ActivateEvent);
}

void ThisDocument_ActivateEvent(object sender, Microsoft.Office.Tools.Word.WindowEventArgs e)
{
    System.Windows.Forms.MessageBox.Show("The document has been activated");
}

.NET Framework-Sicherheit

Siehe auch

Referenz

Document Schnittstelle

Microsoft.Office.Tools.Word-Namespace