Export (0) Print
Expand All

Document.ActivateEvent Event

Occurs when the document becomes the active window.

Namespace:  Microsoft.Office.Tools.Word
Assemblies:   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)

event WindowEventHandler ActivateEvent

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.

The following code snippet displays a message when the document is activated. This example is for an application-level add-in.

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

Show:
© 2014 Microsoft