View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Newbie1 Newbie1 is offline
external usenet poster
 
Posts: 6
Default Button to close without saving

Tom

Exactly what I wanted - Thanks

Kenny (Newbie1)

"Tom Ogilvy" wrote in message
...
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.

--
Regards,
Tom Ogilvy


"Newbie1" wrote in message
...
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

"Chip Pearson" wrote in message
...
Kenny,

Use something like

ThisWorkbook.Close SaveChanges:=False


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Newbie1" wrote in message
...
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