Creates a new workbook. The new workbook becomes the active workbook.
Syntax
expression.Add (Template)
expression A variable that represents a Workbooks object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Template | Optional | Variant | Determines how the new workbook is created. If this argument is a string specifying the name of an existing Microsoft Excel file, the new workbook is created with the specified file as a template.
If this argument is a constant, the new workbook contains a single sheet of the specified type. Can be one of the following XlWBATemplate constants: xlWBATChart, xlWBATExcel4IntlMacroSheet, xlWBATExcel4MacroSheet, or xlWBATWorksheet. If this argument is omitted, Microsoft Excel creates a new workbook with a number of blank sheets (the number of sheets is set by the SheetsInNewWorkbook property). |
XlWBATemplate
Specifies the type of workbook to create. The new workbook contains a single sheet of the specified type.
Name | Value | Description |
---|---|---|
xlWBATChart | -4109 | Chart |
xlWBATExcel4IntlMacroSheet | 4 | Excel version 4 macro |
xlWBATExcel4MacroSheet | 3 | Excel version 4 international macro |
xlWBATWorksheet | -4167 | Worksheet |
SheetsInNewWorkbook
Returns or sets the number of sheets that Microsoft Excel automatically inserts into new workbooks. Read/write Long.
This example sets the number of sheets automatically inserted into new workbooks equal to 3.
Application.SheetsInNewWorkbook = 3
This example displays the number of sheets automatically inserted into new workbooks.
MsgBox "Microsoft Excel inserts " & _
Application.SheetsInNewWorkbook & _
" sheet(s) in each new workbook"
Return value
A Workbook object that represents the new workbook.
Remarks
If the Template argument specifies a file, the file name can include a path.
Examples
Use the Add method to create a new, empty workbook and add it to the collection.
The following example adds a new, empty workbook to Microsoft Excel.
Workbooks.Add
The following example adds a new, empty Chart workbook to Microsoft Excel.
Workbooks.Add xlWBATChart