Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old June 20th 18, 09:12 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jan 2015
Posts: 39
Default Save and Close

Is there code I can put into a my personal workbook which would allow me to save and close all of open workbooks? I have several that are quite large and often end up with a dozen open at the end of the day, so it would be a time saver.
Thanks!

  #2   Report Post  
Old June 21st 18, 03:49 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jan 2015
Posts: 39
Default Save and Close

On Wednesday, June 20, 2018 at 4:12:53 PM UTC-4, Paul Doucette wrote:
Is there code I can put into a my personal workbook which would allow me to save and close all of open workbooks? I have several that are quite large and often end up with a dozen open at the end of the day, so it would be a time saver.
Thanks!


Thanks Claus!

Sub CloseAndSave()
Dim wbk As Workbook

Application.ScreenUpdating = False
For Each wbk In Workbooks
If wbk.Name < ThisWorkbook.Name Then
wbk.Close True
End If
Next
Application.ScreenUpdating = True
Application.Quit
End Sub
  #3   Report Post  
Old June 21st 18, 05:36 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2018
Posts: 3
Default Save and Close

On Thursday, June 21, 2018 at 10:49:17 AM UTC-4, Paul Doucette wrote:
On Wednesday, June 20, 2018 at 4:12:53 PM UTC-4, Paul Doucette wrote:
Is there code I can put into a my personal workbook which would allow me to save and close all of open workbooks? I have several that are quite large and often end up with a dozen open at the end of the day, so it would be a time saver.
Thanks!


Thanks Claus!

Sub CloseAndSave()
Dim wbk As Workbook

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


I would add a check to see whether it is Read-only or not, otherwise you could get a runtime error.
  #4   Report Post  
Old June 21st 18, 05:43 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jan 2015
Posts: 39
Default Save and Close

On Thursday, June 21, 2018 at 12:37:04 PM UTC-4, Ilia Asafiev wrote:
On Thursday, June 21, 2018 at 10:49:17 AM UTC-4, Paul Doucette wrote:
On Wednesday, June 20, 2018 at 4:12:53 PM UTC-4, Paul Doucette wrote:
Is there code I can put into a my personal workbook which would allow me to save and close all of open workbooks? I have several that are quite large and often end up with a dozen open at the end of the day, so it would be a time saver.
Thanks!


Thanks Claus!

Sub CloseAndSave()
Dim wbk As Workbook

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


I would add a check to see whether it is Read-only or not, otherwise you could get a runtime error.


Thanks!


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
Save/Close All M Scott Excel Discussion (Misc queries) 1 February 6th 07 02:12 AM
To save and close Steved Excel Worksheet Functions 5 July 27th 05 12:17 AM
Save and Close Pop Up Box...After Save and Close In VBA Celtic_Avenger[_47_] Excel Programming 0 October 11th 04 05:46 AM
Save and Close Pop Up Box...After Save and Close In VBA Celtic_Avenger[_12_] Excel Programming 3 September 11th 04 10:58 PM
Close without save Jesse[_5_] Excel Programming 3 May 7th 04 12:03 AM


All times are GMT +1. The time now is 10:33 AM.

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017