VBA & Macro Problems

How to Save All Open Documents in Word Using a VBA Macro

Amos GikundaAmos Gikunda Oct 26, 2026 870 views

Question details

The user wants to create a VBA macro to automatically save every open Word document in a single action, rather than saving them individually.

How to Save All Open Word Documents Using a VBA Macro
Product
Word
Device & OS
not provided
Scenario
Managing multiple open documents and needing a bulk save action without repeatedly clicking save for each active window.
Observed behavior
Word's default save function only saves the currently active document. A VBA loop is required to iterate through and save the entire open Documents collection.
Before you start

Before running the macro, ensure that you have enabled the Developer tab in Word and that your macro security settings are configured to allow VBA scripts to run.

Solution 1Recommended

Use a VBA Loop to Save All Open Documents (Skips Unsaved Files)

Create a macro that iterates through the Documents collection and saves each one, explicitly skipping brand-new, unnamed files to prevent the 'Save As' prompt from interrupting the automation.

This is the most efficient method for saving multiple documents you are already working on. By checking the document's file path, the macro intelligently ignores entirely new files that haven't been saved to your drive yet.

1
Open the VBA Editor

Open Word and press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) Editor.

2
Insert a New Module

In the VBA Editor, click on 'Insert' in the top menu bar, and then select 'Module' to create a blank script window.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub SaveAllOpenDocs() Dim D As Document For Each D In Documents If D.Path <> "" Then D.Save Next End Sub

4
Run the Macro

Press F5 or click the 'Run' button (the green triangle) in the toolbar to execute the macro. All documents with an existing file path will be saved instantly.

Use a VBA Loop to Save All Open Documents (Skips Unsaved Files)
Preventing Interruptions: The 'If D.Path <> ""' condition is crucial. It ensures the script doesn't halt to ask for a file name when it encounters a completely new, unsaved document (like 'Document1').
Efficient Document Management

Save Multiple Documents Effortlessly in WPS Writer

WPS Office Writer provides a seamless environment for managing multiple documents. Not only does it support advanced VBA macros for custom automation, but its tabbed interface allows you to easily manage, navigate, and save multiple open files within a single window.

  1. 1. Open Documents in Tabs: Open multiple documents in WPS Writer. Notice how they arrange neatly in tabs at the top, just like a web browser.
  2. 2. Access the Macro Editor: Press Alt + F11 to open the built-in WPS Macro Editor (available in versions with VBA support installed).
  3. 3. Run the Save Macro: Paste the VBA script provided in the solutions above to save all your open documents instantly.
Fully compatible with Microsoft Word .docx formats and standard VBA scripts.Intuitive tabbed document interface keeps your workspace organized.Lightweight architecture runs smoothly even with dozens of files open.Free to download with premium macro capabilities available for power users.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my macro stop and ask for a file name?

If an open document has never been saved before, it does not have an established file path on your computer. The standard `D.Save` command triggers the 'Save As' dialog for these files. You can bypass this by adding an `If D.Path <> ""` check to your VBA loop.

Can I add a confirmation message when all documents are saved?

Yes, you can add `MsgBox "All documents saved!"` right before the `End Sub` line in your macro. This will display a pop-up alert once the entire saving process is complete.

How do I assign this macro to a quick access button?

In Word, go to File > Options > Quick Access Toolbar. Select 'Macros' from the 'Choose commands from' drop-down list, find your save macro in the list, and click 'Add' to place it on your toolbar for simple one-click access.

Will this macro automatically close the documents after saving them?

No, the provided VBA loop only executes the save command. The documents will remain open on your screen. If you want to close them simultaneously, you would need to add the `D.Close` command right after `D.Save` inside the loop.