Share via


DocumentBase.ActivateEvent 事件

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

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

語法

'宣告
Public Event ActivateEvent As WindowEventHandler
public event WindowEventHandler ActivateEvent

備註

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

範例

下列程式碼片段會在啟動文件時顯示訊息。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentActivateEvent()
    AddHandler Me.ActivateEvent, AddressOf ThisDocument_ActivateEvent
End Sub

Private Sub ThisDocument_ActivateEvent(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
    MessageBox.Show("The document has been activated")
End Sub
private void DocumentActivateEvent()
{
    this.ActivateEvent += new Microsoft.Office.Tools.Word.WindowEventHandler(ThisDocument_ActivateEvent);
}

void ThisDocument_ActivateEvent(object sender, Microsoft.Office.Tools.Word.WindowEventArgs e)
{
    MessageBox.Show("The document has been activated");
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間