Button to close without saving

  • Thread starter Thread starter Newbie1
  • Start date Start date
N

Newbie1

Hello

I am trying to create code for a commandbutton on a userform which will
close the workbook without saving.

Using <Application.quit> throws up a message box giving the user a choice
(which I do not want!)

Is there something similar to <ThisWorkbook.Save> (but obviously does not
save!)

Thanks

Kenny
 
Hello Chip

Still not quite what I wanted!

I used
Private Sub CommandButton3_Click()

ThisWorkbook.Close SaveChanges:=False
Application.Quit
End Sub

However the file closed but left the Excel menu bar on the screen which I
had to close manually.

When I use:- (on another button)

Sub ChooseNo()
Unload UserForm2
ThisWorkbook.Save
Application.Quit
End Sub

Excel closes completely - This is what I am trying to achieve -
any ideas what I am doing wrong?

Kenny
 
When the workbook closes, the code stops, so you never hit quit

In your second example, you don't close the workbook, you just save it.

try this


Private Sub CommandButton3_Click()

ThisWorkbook.Saved=True
Application.Quit
End Sub

Setting Saved = True should tell Excel the workbook does not need to be
saved and it should close without prompting.
 
Back
Top