Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners -
https://partner.microsoft.com/global/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryserviceFor more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
In Microsoft Excel, you can use the AUTOSAVE.XLA add-in macro to save all
open documents automatically as you work. If you prefer not to have your
documents automatically saved, but would like to save all open documents
at one time, you can create and use a sample macro that performs the same action as opening each workbook and then clicking
Save on the
File menu.
Create the Macro
- In Excel, press ALT+F11 to start the visual basic editor.
- On the Insert menu, click Module.
- In the module sheet, type the following code:
Sub SaveAll()
' Store the Activeworkbook in a variable.
Set aw = ActiveWorkbook
For Each wb In Workbooks
If wb.Path <> "" Then ' Save file if it has been saved
' previously
wb.Save
Else ' If not previously saved, activate and show the
' Save As dialog box.
wb.Activate
Application.Dialogs(xlDialogSaveAs).Show
End If
Next
aw.Activate ' Activate the original Activeworkbook.
End Sub
- Press ALT+Fll to return to Excel.
Place the Macro in a Menu
If you want to create a menu item to run the macro, follow these steps:
- On the View menu, point to Toolbars, and then click Customize.
- Click the Commands tab.
- In Categories list , click Macros.
- Under Commands, drag Custom Menu Item to the File menu.
NOTE: Wait for the File menu to open and then drop Custom Menu Item into the menu. - On the File menu, Right-click Custom Menu Item.
- In the Name box on the shortcut menu, type Save &All.
- Click Assign Macro on the shortcut menu.
- In the Macro name list, click SaveAll, and then click OK.
- In the Customize dialog box, click Close.
To run the macro and save all open workbooks, click
Save All on the
File menu. You can create this macro and make the menu changes in a new workbook or in an existing workbook.
TIP: To make the menu choice always available in Microsoft Excel, store the macro and make the menu changes in a Personal Macro Workbook, and then always open the Personal Macro Workbook when you are using Excel.