Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to SAVE and EXIT from EXCEL
The heading says it all.
I want to save any open Excel files and then Close Excel Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to SAVE and EXIT from EXCEL
pcorcele wrote:
The heading says it all. I want to save any open Excel files and then Close Excel Thanks Try this, edit to suit: Sub SaveAllAndExit() Dim Book As Workbook For Each Book In Workbooks 'assumes Windows; Macs use ":" (or perhaps "/", no clue) If InStr(Book.FullName, "\") < 1 Then MsgBox "At least one workbook is new." & vbNewLine & _ "Manually save it before running this macro.", vbCritical Exit Sub End If Next For Each Book In Workbooks If UCase$(Left$(Book.Name, 11)) < "PERSONAL.XL" Then Book.Save Book.RunAutoMacros xlAutoClose End If Next Workbooks.Close Application.Quit End Sub -- It's time to save the world from itself. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to SAVE and EXIT from EXCEL
Option Explicit
Sub Save_close() 'Whichever file contains this code will remain open in the end Dim wb As Workbook For Each wb In Workbooks If wb.Name = ThisWorkbook.Name Then 'do nothing Else wb.Close savechanges:=True End If Next wb End Sub On Monday, 25 November 2013 05:38:15 UTC+5:30, pcorcele wrote: The heading says it all. I want to save any open Excel files and then Close Excel Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
save and exit macro | Excel Programming | |||
Save/exit macro | Excel Programming | |||
Excel Save as & Exit macro | Excel Programming | |||
Write macro don't ask to save when exit excel | Excel Programming | |||
Macro: Exit active workbook without save? | Excel Worksheet Functions |