ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save and Close all Open Workbooks using VBScript (https://www.excelbanter.com/excel-programming/317191-save-close-all-open-workbooks-using-vbscript.html)

Rick De Marco

Save and Close all Open Workbooks using VBScript
 
Hi,

Doea anyone know how to automatically save and close all open workbooks?

Thanks, Rick

Sharad Naik

Save and Close all Open Workbooks using VBScript
 
can be done as under, two options: In 2nd option, Excel is closed.

Sub closing()
ThisWorkbook.Activate
For Each Window In Application.Windows
If Not Window.Index = ActiveWindow.Index Then
Window.Close Savechanges:=True
End If
Next Window
ThisWorkbook.Close Savechanges:=True
End Sub

OR

Sub quitting()
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
End Sub



"Rick De Marco" wrote in message
m...
Hi,

Doea anyone know how to automatically save and close all open workbooks?

Thanks, Rick





All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com