Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Button to close without saving

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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Button to close without saving

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







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Button to close without saving

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









  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Button to close without saving

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











  #5   Report Post  
Posted to microsoft.public.excel.programming
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















Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
close without saving calebjill Excel Discussion (Misc queries) 1 January 29th 09 11:16 PM
close w/o saving jatman Excel Worksheet Functions 5 February 29th 08 02:52 PM
VBA - Close without saving changes PaulW Excel Discussion (Misc queries) 2 July 27th 06 01:22 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"