Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Exit without saving in a macro

I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting and I
want to say no in the macro)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Exit without saving in a macro

In the before close event add
ThisWorkbook.Saved = True

This is the flag that Excel uses to determine if the file needs to be saved
and the code above say that the file does not need to be saved. Don't place
any code after this line as that could change the spreadsheet and flip the
flag back again.
--
HTH...

Jim Thomlinson


"Brian" wrote:

I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting and I
want to say no in the macro)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Exit without saving in a macro

Hi Brian,
you can use:

Worksheets("yourworksheets").close Savechanges:= false

This is best way to do it, and never ask you about save changes.



"Brian" escreveu:

I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting and I
want to say no in the macro)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Exit without saving in a macro

Your code does not work. Close is not a method of the worksheets object. It
is a method of the workbook. You could use

Thisworkbook.Close SaveChanges:=False

but it requires that the user close the workbook via a command button or
such to execute this line of code. If the user closes the workbook via the x
then this code never executes and the user is prompted about saving...
--
HTH...

Jim Thomlinson


"Renato M. T." wrote:

Hi Brian,
you can use:

Worksheets("yourworksheets").close Savechanges:= false

This is best way to do it, and never ask you about save changes.



"Brian" escreveu:

I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting and I
want to say no in the macro)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Exit without saving in a macro

I have a macro that closes a worksheet

If it's a worksheet, and not a workbook, perhaps...

Sub Demo()
Application.DisplayAlerts = False
Worksheets(1).Delete
Application.DisplayAlerts = True
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Brian" wrote in message
...
I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting
and I
want to say no in the macro)



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
Exit a worksheet with out saving changes Sherry Excel Discussion (Misc queries) 2 October 24th 08 05:26 PM
Exit with out saving Greg[_27_] Excel Programming 4 May 12th 06 07:07 PM
Exit via macro only? Brisbane Rob Excel Discussion (Misc queries) 1 October 13th 05 01:16 PM
on exit macro ditchy Excel Discussion (Misc queries) 2 May 3rd 05 12:11 AM
Saving Procdb.xla on exit from Excel JD Excel Programming 3 June 2nd 04 04:52 PM


All times are GMT +1. The time now is 07:53 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"