Workbook.Close method (Excel)
Closes the object.
Syntax
expression.Close (SaveChanges, FileName, RouteWorkbook)
expression A variable that represents a Workbook object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
SaveChanges | Optional | Variant | If there are no changes to the workbook, this argument is ignored. If there are changes to the workbook and the workbook appears in other open windows, this argument is ignored. If there are changes to the workbook but the workbook doesn't appear in any other open windows, this argument specifies whether changes should be saved. If set to True, changes are saved to the workbook. If there is not yet a file name associated with the workbook, FileName is used. If FileName is omitted, the user is asked to supply a file name. |
FileName | Optional | Variant | Saves changes under this file name. |
RouteWorkbook | Optional | Variant | If the workbook doesn't need to be routed to the next recipient (if it has no routing slip or has already been routed), this argument is ignored. Otherwise, Microsoft Excel routes the workbook according to the value of this parameter. If set to True, the workbook is sent to the next recipient. If set to False, the workbook is not sent. If omitted, the user is asked whether the workbook should be sent. |
Remarks
Closing a workbook from Visual Basic doesn't run any Auto_Close macros in the workbook. Use the RunAutoMacros method to run the Auto_Close macros.
Example
This example closes Book1.xls and discards any changes that have been made to it.
Workbooks("BOOK1.XLS").Close SaveChanges:=False
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기