DocumentBase.New Event

Definition

Occurs when a new document is created.

public:
 event Microsoft::Office::Interop::Word::DocumentEvents2_NewEventHandler ^ New;
public event Microsoft.Office.Interop.Word.DocumentEvents2_NewEventHandler New;
member this.New : Microsoft.Office.Interop.Word.DocumentEvents2_NewEventHandler 
Public Custom Event New As DocumentEvents2_NewEventHandler 

Event Type

Examples

The following code example creates an event handler to display a message when a new document is created. To use this example, run it from the ThisDocument class in a Word Template project.

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

Remarks

This event is only raised when a new document is created from a template.

Applies to