LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to save & close all opened files

Hi James,

I don't know about closing all files, but to close save and close all
Excel workbooks, put this macro in a common module or ThisWorkbook
module. This will save the workbook with the code last and then close
the entire excel application.

Sub CloseWorkbooks()

Dim wkbk As Workbook

'loop through workbook collection
For Each wkbk In Application.Workbooks
If wkbk.Name < ThisWorkbook.Name Then
wkbk.Close True
Else
End If
Next wkbk

'save this workbook
ThisWorkbook.Save
'close the excel application
Application.Quit
End Sub

Regards,

Tim

James A wrote:
Is there any way to record a macro to save and close alll open files?
--
James A


 
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
Macro Help (Uppercase multiple ranges?) Ken Excel Discussion (Misc queries) 14 December 2nd 06 07:23 PM
Run multiple excel files off of one macro. ahsya Excel Discussion (Misc queries) 5 October 4th 06 03:01 PM
Cannot save excel files to a folder on a network Robbie Excel Discussion (Misc queries) 1 June 9th 06 07:26 AM
Save a Macro ducttape Excel Discussion (Misc queries) 3 February 20th 06 04:46 PM
can't save newly opened files Rasoul Khoshravan Excel Discussion (Misc queries) 1 December 9th 04 07:27 AM


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

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"