Programmatically create new workbooks

When you create a workbook programmatically, it is a native Workbook object, not a Workbook host item.

Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.

You can generate a Workbook host item for a Workbook object in VSTO Add-in project. For more information, see Extend Word documents and Excel workbooks in VSTO Add-ins at run time.

To create a new workbook

  1. Use the Add method of the Workbooks collection.

    Excel.Workbook newWorkbook = this.Application.Workbooks.Add();
    

    Note

    You can create a workbook based on a template other than the default template: pass the template you want to use as a parameter to the Add method.