Document.Deactivate Event


Occurs when the active document window loses focus.

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

event WindowEventHandler Deactivate

The Deactivate event does not occur when you unload the document.

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

private void DocumentDeactivate()
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Deactivate += new Microsoft.Office.Tools.Word.WindowEventHandler(ThisDocument_Deactivate);

void ThisDocument_Deactivate(object sender, Microsoft.Office.Tools.Word.WindowEventArgs e)
    System.Windows.Forms.MessageBox.Show ("The document has been deactivated");
Return to top