|  

» Close a workbook using VBA in Microsoft Excel

VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
If you just want to close a workbook without the user being prompted for any confirmations
about saving the workbook you can simply do this :
ActiveWorkbook.Close False 
' closes the active workbook without saving any changes

ActiveWorkbook.Close True 
' closes the active workbook and saves any changes

ActiveWorkbook.Close 
' closes the active workbook and lets the user decide if 
' changes are to be saved or not



Rate This Tip
12 34 5
Rating: 4.22     Views: 128988
Clipboard Nuissance
Huade
When I auto close out of a workbook with a lot of information stored on the clipboard, even when I use the do not save changes option, excel prompts me to save the data on the clipboard. Is there a way to clear the clipboard through VBA before closing a workbook?
Re: Clipboard Nuisance
Charvak Karpe
I also had this problem. Try
Application.CutCopyMode = False
to clear the clipboard.

You could also just copy a single cell to avoid the problem, but clearing it makes the most sense.
Click here to post comment
For Registered Users
Name
Comment Title
Comments