• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Exit workbook without save

inddon

Member
Hello There,

I have a workbook, whose functionality is, it should close the workbook without saving anychanges and without any popups to save the workbook:

In the Private Sub Workbook_Open, there are certain Call to some Sub's.
In all the Sub's related to Workbook_Open, there is the below code. It sets a global variable to True which I intend to use it in workbook_beforeclose to identify a normal close or a close by error in the subs
Code:
InvalidCheck = True
Thisworkbook.close savechanges=False

What code should I write in the Private Sub Workbook_BeforeClose, the workbook exit without saving or asking standard question to save?
In here, there is custom message question "Do you want to exit the application?".
When the Workbook_Open goes all okay and the User clicks on exit workbook, therefore the above custom message


Thank you for your help and look forward to hearing from you

Regards,
Don
 
inddon
Exit workbook without save
You're writing ... many things.
Copy next to Thisworkbook (Code)
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
End Sub
... and try to save file.
If You would let someway to save that file then You could add 'Msgbox'-question for that.
 
Last edited:
Back
Top