Document.ActivateEvent 事件

當文件成為使用中視窗時發生。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
Event ActivateEvent As WindowEventHandler
event WindowEventHandler ActivateEvent

備註

只有當您在應用程式中移動焦點時,才會發生 ActivateEvent 事件。 將焦點移至其他應用程式中的物件,或從該物件移開焦點,都不會觸發事件。

範例

下列程式碼片段會在啟動文件時顯示訊息。 這是應用程式層級增益集的範例。

Private Sub DocumentActivateEvent()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.ActivateEvent, AddressOf ThisDocument_ActivateEvent
End Sub

Private Sub ThisDocument_ActivateEvent(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
    System.Windows.Forms.MessageBox.Show("The document has been activated")
End Sub
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");
}

.NET Framework 安全性

請參閱

參考

Document 介面

Microsoft.Office.Tools.Word 命名空間