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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access