Creating a New Workbook

If you need to create a new workbook, use the Workbooks collection's Add method: Workbooks.Add(Template)

Template is an optional argument that determines how the workbook is created. If Template is a string specifying an Excel file, VBA uses the file as a template for the new workbook. You also can specify one of the following constants:

xlWBATWorksheet Creates a workbook with a single worksheet.

xlWBATChart Creates a workbook with a single chart sheet.

Here's a sample statement that uses the Add method to open a new workbook based on Excel's ExpenseReport.xltx template file:

Workbooks.Add "C:\Program Files\Microsoft Office" & _ "\Templates\1033\ExpenseReport.xltx"

0 0

Post a comment