Name
workbook
.Close([SaveChanges
], [Filename
], [RouteWorkbook
])
Synopsis
Closes an open workbook and optionally saves changes or distributes that workbook to a routing list. When used with the Workbooks
collection, closes all open workbooks in the current instance of Excel. The following arguments apply to closing a single workbook.
Argument |
Settings |
---|---|
|
True saves current changes; False does not save changes. The default is to prompt the user. |
|
If |
|
If the workbook has a routing list, True routes the workbook; False does not route. The default is to prompt. |
The Close
method does not run Auto_Close
macros, but it does trigger the Before_Close
event.
The following code closes all open workbooks. If any of the workbooks has unsaved changes, the user is prompted whether they should be saved:
Workbooks.Close
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.