Dela via


Workbook.New Event (2007 System)

Occurs when a new workbook is created.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Event New As WorkbookEvents_NewEventHandler
'Usage
Dim instance As Workbook 
Dim handler As WorkbookEvents_NewEventHandler 

AddHandler instance.New, handler
public event WorkbookEvents_NewEventHandler New
public:
 event WorkbookEvents_NewEventHandler^ New {
    void add (WorkbookEvents_NewEventHandler^ value);
    void remove (WorkbookEvents_NewEventHandler^ value);
}
JScript does not support events.

Examples

The following code example demonstrates a handler for the New event. The event handler maximizes the Microsoft Office Excel application window when a new workbook is created.

This example is for a document-level customization.

Sub ThisWorkbook_New() Handles Me.New 
    Me.Application.WindowState = Excel.XlWindowState.xlMaximized
End Sub
private void WorkbookNew()
{
    this.New +=
        new Microsoft.Office.Tools.Excel.WorkbookEvents_NewEventHandler(
        ThisWorkbook_New);
}

void ThisWorkbook_New()
{
    this.Application.WindowState = Excel.XlWindowState.xlMaximized;
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace