Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Close all without saving and exit without prompts



HI All

I'm trying to find a macro to close all open worksheets without saving
and exit Excel without prompts.

When I run the macro , Excel just closes with no popups of any kind. No
worksheets need to be saved.

Can someone help?


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Close all without saving and exit without prompts

hi Colin,

Am Sun, 17 Nov 2013 14:50:16 +0000 schrieb Colin Hayes:

I'm trying to find a macro to close all open worksheets without saving
and exit Excel without prompts.


try:

Sub Test()
Dim wbk As Workbook

For Each wbk In Workbooks
If wbk.Name < ThisWorkbook.Name Then
wbk.Close savechanges:=False
End If
Next
With Application
.DisplayAlerts = False
.Quit
.DisplayAlerts = True
End With
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Close all without saving and exit without prompts

In article , Claus Busch
writes
hi Colin,

Am Sun, 17 Nov 2013 14:50:16 +0000 schrieb Colin Hayes:

I'm trying to find a macro to close all open worksheets without saving
and exit Excel without prompts.


try:

Sub Test()
Dim wbk As Workbook

For Each wbk In Workbooks
If wbk.Name < ThisWorkbook.Name Then
wbk.Close savechanges:=False
End If
Next
With Application
.DisplayAlerts = False
.Quit
.DisplayAlerts = True
End With
End Sub


Regards
Claus B.


Hi Claus

OK thanks for this and again for your help.

I find it works fine for worksheets opened after the initial opening
sheet (book1), but still give prompts where any change in book1 or it's
macros has been made.

Worksheets opened and changed after this are close without prompt ,
which is correct.

What do you think?


Best Wishes


Colin


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Close all without saving and exit without prompts

Hi Colin,

Am Sun, 17 Nov 2013 17:15:56 +0000 schrieb Colin Hayes:

I find it works fine for worksheets opened after the initial opening
sheet (book1), but still give prompts where any change in book1 or it's
macros has been made.


and you also don't want to save book1?


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default Close all without saving and exit without prompts

I'm inclined to go with this modified version of Claus' offering...

Sub Test()
Dim wkb As Workbook

For Each wbk In Workbooks
If wkb.Visible And wkb < ThisWorkbook Then _
wkb.Close SaveChanges:=False
Next
With Application
.DisplayAlerts = False: .Quit: .DisplayAlerts = True
End With
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,514
Default Close all without saving and exit without prompts

Typo...

I'm inclined to go with this modified version of Claus' offering...

Sub Test()
Dim wkb As Workbook

For Each wkb In Workbooks
If wkb.Visible And wkb < ThisWorkbook Then _
wkb.Close SaveChanges:=False
Next
With Application
.DisplayAlerts = False: .Quit: .DisplayAlerts = True
End With
End Sub


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Close all without saving and exit without prompts

Hi Colin,

Am Sun, 17 Nov 2013 17:15:56 +0000 schrieb Colin Hayes:

I find it works fine for worksheets opened after the initial opening
sheet (book1), but still give prompts where any change in book1 or it's
macros has been made.


then try:

Sub Test()
Dim wbk As Workbook

For Each wbk In Workbooks
If wbk.Name < ThisWorkbook.Name Then
wbk.Close savechanges:=False
End If
Next
ThisWorkbook.Saved = True
Application.Quit
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Close all without saving and exit without prompts

Hi Garry,

Am Sun, 17 Nov 2013 12:46:49 -0500 schrieb GS:

.DisplayAlerts = False: .Quit: .DisplayAlerts = True


still you set DisplayAlerts to false with Quit the prompt is shown.
Only solution is ThisWorkbook.Saved=True


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Close all without saving and exit without prompts

In article , Claus Busch
writes
Hi Colin,

Sub Test()
Dim wbk As Workbook

For Each wbk In Workbooks
If wbk.Name < ThisWorkbook.Name Then
wbk.Close savechanges:=False
End If
Next
ThisWorkbook.Saved = True
Application.Quit
End Sub


Regards
Claus B.



HI Guys

OK thanks for this. All working fine now.

Everything closes with no saving and no prompts at all. Perfect.


^_^



Best Wishes


Colin
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/open workbook without prompts [email protected] Excel Programming 5 June 29th 08 07:16 PM
Prompts to Discard digital signature while saving Jaydeep Excel Programming 0 April 12th 07 01:00 PM
Saving Prompts Colin Hayes Excel Worksheet Functions 2 March 14th 07 03:02 PM
When saving CSV excel always prompts about the file format SimonW-UK Excel Discussion (Misc queries) 2 November 16th 05 10:34 AM
Saving a single Worksheet w/o redundant prompts Jeff Harbin[_4_] Excel Programming 3 November 13th 05 09:22 PM


All times are GMT +1. The time now is 11:49 PM.

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

About Us

"It's about Microsoft Excel"