Document.New Event (2007 System)
Occurs when a new document is created.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Event New As DocumentEvents2_NewEventHandler
'Usage
Dim instance As Document
Dim handler As DocumentEvents2_NewEventHandler
AddHandler instance.New, handler
public event DocumentEvents2_NewEventHandler New
public:
event DocumentEvents2_NewEventHandler^ New {
void add (DocumentEvents2_NewEventHandler^ value);
void remove (DocumentEvents2_NewEventHandler^ value);
}
JScript does not support events.
Remarks
This event is only raised when a new document is created from a template.
Examples
The following code example creates an event handler to display a message when a new document is created. The example assumes that the code is run from a Microsoft Office Word template.
This example is for a document-level customization.
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
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.");
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.