DocumentBase.New 事件

定义

在创建新文档时发生。

public event Microsoft.Office.Interop.Word.DocumentEvents2_NewEventHandler New;

事件类型

DocumentEvents2_NewEventHandler

示例

下面的代码示例创建一个事件处理程序,以便在创建新文档时显示一条消息。 若要使用此示例,请从 ThisDocument Word 模板项目的类中运行它。

private void DocumentNew()
{
    this.New += new Microsoft.Office.Interop.Word.
        DocumentEvents2_NewEventHandler(
        ThisDocument_New);
}

void ThisDocument_New()
{
    MessageBox.Show("The Document.New event has fired.");
}
Private Sub DocumentNew()
    AddHandler Me.New, AddressOf ThisDocument_New
End Sub

Private Sub ThisDocument_New()
    MessageBox.Show("The Document.New event has fired.")
End Sub

注解

仅当从模板创建新文档时才会引发此事件。

适用于