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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。