The Workbook Object

Each Workbook object represents an open .XLS or .XLA file. When you open Excel as a normal application (not from VBA), it automatically creates a new, blank workbook. When you start Excel from VBA, however, it does not contain any workbooks and your code must create any that you will need.

Opening and Creating Workbooks

To create a new workbook, use the Workbooks collection's Add method:

Workbooks.Add(Template)

The Template argument specifies the name of the .XLS file to use as the template for the new workbook, or one of the xlWBATemplate defined constants (viewable in the Object Browser). When you specify a constant, the new workbook contains a single worksheet of the specified type. If the Template argument is omitted, ...

Get Office® XP Development with VBA 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.