Document.Deactivate 事件

在活动文档窗口失去焦点时发生。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
Event Deactivate As WindowEventHandler
event WindowEventHandler Deactivate

备注

Deactivate 事件不会在您卸载文档时发生。

示例

下面的代码示例在文档被停用时显示一条消息。 此示例针对的是应用程序级外接程序。

Private Sub DocumentDeactivate()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    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 = 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");
}

.NET Framework 安全性

请参见

参考

Document 接口

Microsoft.Office.Tools.Word 命名空间