Document.Deactivate Event (2007 System)
Occurs when the active document window loses focus.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Event Deactivate As WindowEventHandler
'Usage
Dim instance As Document
Dim handler As WindowEventHandler
AddHandler instance.Deactivate, handler
public event WindowEventHandler Deactivate
public:
event WindowEventHandler^ Deactivate {
void add (WindowEventHandler^ value);
void remove (WindowEventHandler^ value);
}
JScript does not support events.
Remarks
The Deactivate event does not occur when you unload the document.
Examples
The following code example displays a message when the document is deactivated.
This version is for a document-level customization.
Private Sub DocumentDeactivate()
AddHandler Me.Deactivate, AddressOf ThisDocument_Deactivate
End Sub
Private Sub ThisDocument_Deactivate(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
MessageBox.Show("The document has been deactivated")
End Sub
private void DocumentDeactivate()
{
this.Deactivate += new Microsoft.Office.Tools.Word.WindowEventHandler(ThisDocument_Deactivate);
}
void ThisDocument_Deactivate(object sender, Microsoft.Office.Tools.Word.WindowEventArgs e)
{
MessageBox.Show ("The document has been deactivated");
}
This version is for an application-level add-in.
Private Sub DocumentDeactivate()
Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
AddHandler vstoDoc.Deactivate, AddressOf ThisDocument_Deactivate
End Sub
Private Sub ThisDocument_Deactivate(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
System.Windows.Forms.MessageBox.Show("The document has been deactivated")
End Sub
private void DocumentDeactivate()
{
Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
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");
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Office.Tools.Word Namespace
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Added a version of the code example for an application-level add-in. |
SP1 feature change. |