Add Method

The Add method creates a new workbook, which is then added to the Workbooks collection. The new workbook becomes the active workbook. The syntax is:

WorkbooksObject.Add(Template)

where the optional Template parameter determines how the new workbook is created. If this argument is a string specifying the name of an existing Excel template file, the new workbook is created with that file as a template.

As you may know, a template is an Excel workbook that may contain content (such as row and column labels), formatting, and macros and other customizations (menus and toolbars, for instance). When you base a new workbook on a template, the new workbook receives the content, formatting, and customization from the template.

The Template argument can also be one of the following constants:

Enum XlWBATemplate xlWBATWorksheet = -4167 xlWBATChart = -4109 xlWBATExcel4MacroSheet = 3 xlWBATExcel4IntlMacroSheet = 4 End Enum

In this case, the new workbook will contain a single sheet of the specified type. If the Template argument is omitted, Excel will create a new workbook with the number of blank sheets set by the Application object's SheetsInNewWorkbook property.

0 0

Post a comment