Name

workbooks.Add([Template])

Synopsis

Creates a new workbook and opens it in Excel.

Argument

Settings

Template

The filename of a template to base the new workbook on. Alternately, this argument may be one of the following XlWBATemplate settings: xlWBATChart, xlWBATExcel4IntlMacroSheet, xlWBATExcel4MacroSheet, or xlWBATWorksheet. In those cases, the new workbook contains a single sheet of the specified type.

After calling Add, the new workbook becomes the ActiveWorkbook in Excel. The following line creates a workbook and returns a reference to the new Workbook object:

Set wb = Application.Workbooks.Add

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.