22.3. Working with Workbooks

In many of your Excel procedures, you'll need to work with Workbooks: creating new Workbooks, saving Workbooks in various locations and formats, opening existing Workbooks, closing Workbooks, and printing Workbooks. To do so, you work with the Workbooks collection, which contains a Workbook object for each open Workbook in Excel.

22.3.1. Creating a Workbook

To create a new Workbook, use the Add method with the Workbooks collection. The syntax is as follows:

Workbooks.Add(Template)

Here, Template is an optional Variant argument that specifies how to create the workbook. The following subsections discuss the available options.

22.3.1.1. Creating a New Blank Workbook

To create a blank Workbook (as if you'd clicked ...

Get Mastering VBA for Microsoft Office 2007, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.