• 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.

Close without saving and reopen the workbook

YasserKhalil

Well-Known Member
Hello everybody
I have a workbook and I need at some point if I made changes that I don't like to run a macro that close the workbook without the prompt of saving and without saving of course
I have this code but I got error message from the application that need to close the application
Code:
Sub SaveCloseReOpen()
    Dim WBK As Excel.Workbook
    Dim Pth As String
   
    Set WBK = ThisWorkbook
    Pth = WBK.FullName
   
    Application.DisplayAlerts = False
        Application.OnTime Now + TimeValue("00:00:05"), Application.Workbooks.Open(Pth)
        WBK.Close (False)
    Application.DisplayAlerts = True
End Sub
 
Hi,

You have written that "I don't like to run a macro that close the workbook without the prompt of saving and without saving of course" but, subject + macro showing interest of just opposite.

So, Take time to explain the goal.

This will close the workbook without saving & prompt. (Paste in ThisWorkbook module).

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Close False
End Sub
 
Mr. Deepak
sorry for not explaining well
I need to close the workbook without saving and at the same time to reopen it again .. this is my goal
Not just close without saving! But also to reopen the workbook again
Hope it is clear now
 
Now What if I need to finish my work ? How can i close the workbook now?
I think I will get rid of that part
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call myClose
End Sub

Last point I need to assign Ctrl + Z to run themacro called "myClose"
 
Simply close the Application window too.

Press Alt+F8 > Select myClose > Hit Options > put small z > Press Ok > Cancel > Ctrl+S
 
Hi,

Work Around is attached.

run stop_close or press Ctrl+q

There's also some other's method do the same but this one quiet simple.
 

Attachments

  • Auto-Reopen.xlsm
    15 KB · Views: 2
Back
Top