How to: Close Workbooks
Updated: July 2008
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.
Microsoft Office version
For more information, see Features Available by Application and Project Type.
You can close the active workbook or you can specify a workbook to close.
There are two procedures for closing the active workbook: one for document-level customizations and one for application-level add-ins.
To close the active workbook in a document-level customization
Call the Close method to close the workbook associated with the customization. To use the following code example, run it in the Sheet1 class in a document-level project for Excel.
To close the active workbook in an application-level add-in
The way that you close a workbook that you specify by name is the same for application-level add-ins and document-level customizations.
To close a workbook that you specify by name
Specify the workbook name as an argument to the Workbooks collection. The following code example assumes that a workbook named NewWorkbook is open in Excel.