Partager via


DocumentBase.ActivateEvent Event

Occurs when the document becomes the active window.

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

Syntax

'Declaration
Public Event ActivateEvent As WindowEventHandler
public event WindowEventHandler ActivateEvent

Remarks

The ActivateEvent event occurs only when you move the focus within an application. Moving the focus to or from an object in another application does not trigger the event.

Examples

The following code snippet displays a message when the document is activated. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentActivateEvent()
    AddHandler Me.ActivateEvent, AddressOf ThisDocument_ActivateEvent
End Sub 

Private Sub ThisDocument_ActivateEvent(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
    MessageBox.Show("The document has been activated")
End Sub
private void DocumentActivateEvent()
{
    this.ActivateEvent += new Microsoft.Office.Tools.Word.WindowEventHandler(ThisDocument_ActivateEvent);
}

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

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace