logo
search
VBA & Macro Problems

Fix Word VBA Merge Error: Cannot Give Document Same Name as Open Document

Adam DavisAdam Davis Sep 28, 2026 868 views

Question details

A Visual Basic program used to generate manuals is failing after a Microsoft 365 update, displaying an error that Word cannot give a document the same name as an open document.

How to Fix Word VBA Merge Error After Microsoft 365 Update
Product
Microsoft Word
Device & OS
not provided
Scenario
Running a VBA macro to perform a document merge and generate an emergency manual after a recent Microsoft 365 suite update.
Observed behavior
The macro execution halts and Word throws an error stating it cannot give a document the same name as an open document, preventing the manual from being generated.
Before you start

Ensure all instances of Microsoft Word and Excel are completely closed, including background processes in the Task Manager, to prevent hidden locked files from conflicting with your macro's save operations.

Solution 1Recommended

Debug and Update VBA File Handling Code

Microsoft 365 updates can change how background processes handle file locking. Updating your VBA code to explicitly close documents and handle errors prevents the file naming conflict.

When VBA attempts to save or open a document using the same name as a file that is already open (even invisibly in the background), Word will block the action. You must step through your code to find the exact line causing the conflict and ensure previous instances are properly closed.

1
Open the VBA Editor

Open your macro-enabled document and press ALT + F11 to launch the Visual Basic for Applications (VBA) Editor.

2
Locate the exact error trigger

Click inside your macro code and press F8 repeatedly to step through the execution line-by-line until the 'same name' error appears. This identifies the problematic SaveAs2 or Open command.

3
Add explicit document closing commands

Right before the line that triggers the error, ensure any previously generated document is closed by adding a line such as: ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges (or specify the exact document object).

4
Release object references

At the end of your merge loop, explicitly release your Word and Excel objects by setting them to Nothing (e.g., Set wdApp = Nothing) to prevent ghost processes from keeping files open.

Debug and Update VBA File Handling Code
Provide exact code for further debugging: If the issue persists, you may need to review the specific file paths and document names dynamically generated by your VBA code to ensure identical names aren't being assigned within the same loop.
Free Microsoft Office alternative

Try WPS Office for Stable VBA and Macro Execution

If unexpected Microsoft 365 updates continue to break your automated scripts, consider switching to WPS Office. It offers a highly compatible and stable environment for running essential VBA macros without the disruption of forced background updates altering your workflows.

Fully compatible with Microsoft Word (.docx, .docm) formatsRobust support for VBA and macro execution for document automationStable environment without disruptive forced background updatesLightweight design ensures faster document loading and processing
microsoft office alternative - wps office

Frequently Asked Questions

Why does Word say I cannot give a document the same name as an open document?

This error occurs when your VBA script attempts to save a new file with a specific name, but a document with that exact name is already open. This is often caused by a hidden background instance of Word holding the file open from a previously crashed macro run.

Can a Microsoft 365 update change how my VBA macros run?

Yes. Office updates frequently alter security settings, background process handling, and occasionally the object model. These changes can cause previously perfectly working VBA macros to suddenly encounter file locking, timing, or permission issues.

How do I prevent file lock errors during a Word mail merge in VBA?

To prevent file locks, ensure your code uses explicit object references rather than relying on ActiveDocument. Always close documents programmatically as soon as you are done with them, and set your COM objects to 'Nothing' before the script finishes.