How to Correctly Close a Word Document from Access VBA
Question details
The user needs to properly close a Word document and quit the Word application via Access VBA to prevent hidden instances of Word from staying open.

- Product
- Microsoft Word / Microsoft Access
- Device & OS
- not provided
- Scenario
- Automating Word document processing from an Access database using VBA scripts.
- Observed behavior
- The WINWORD.EXE process remains running in the background because the VBA routine opens a Word document without explicitly closing it and quitting the application, an issue often caused by using generic references like ActiveDocument.
Ensure you have saved any critical data in your Access database and review your current VBA code to locate where the Word application object is instantiated.
Explicitly declare, close, and release Word objects in VBA
Using specific variables for the Word application and document ensures you have complete control over safely closing files and terminating the background process.
Relying on ActiveDocument in Access VBA can inadvertently reference the wrong instance of Word if a user opens another file simultaneously. Explicitly tracking the application and document objects allows you to safely shut them down.
In your VBA editor, declare your variables clearly. If using early binding, use 'Dim oApp As Word.Application' and 'Dim oDoc As Word.Document'.
Instead of relying on ActiveDocument, assign the document directly to your variable when opening it, such as: 'Set oDoc = oApp.Documents.Open(FileName:=LWordDoc)'.
After your macro finishes processing the data, close the document using 'oDoc.Close SaveChanges:=False'. Change False to True if your macro needs to save the edits.
Free up system memory by setting the document object to nothing using the command 'Set oDoc = Nothing'.
Terminate the Word process completely by executing 'oApp.Quit', and finally, release the application variable with 'Set oApp = Nothing'.

Discover WPS Office for Seamless Document Management
While complex Access VBA integrations rely heavily on the Microsoft Office ecosystem, WPS Office provides a lightweight, highly compatible, and free alternative for your standard Word, Excel, and PowerPoint tasks, complete with macro support in premium versions.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
- 2. Install the application: Run the downloaded installer and follow the quick on-screen prompts to set up WPS Office.
- 3. Open files seamlessly: Double-click your existing .docx or .xlsx files to open them natively in WPS Office with formatting fully preserved.

Frequently Asked Questions
Why does WINWORD.EXE stay open in Task Manager after my macro finishes?
This happens when the VBA code creates a Word Application object but fails to explicitly call the .Quit method or release the object variable (Set oApp = Nothing) before the macro script ends.
What is the difference between early binding and late binding in Access VBA?
Early binding requires setting a reference to the Microsoft Word Object Library in Access, allowing you to declare specific types like Word.Application and utilize IntelliSense. Late binding uses generic Object types, which doesn't require library references but lacks auto-complete features.
Can I use ActiveDocument instead of specific variables in Access VBA?
It is highly discouraged. Using ActiveDocument from an external application like Access can reference the wrong Word instance if the user opens another document simultaneously, leading to unexpected errors or orphaned processes.
How do I save changes before closing the Word document via VBA?
Change the parameter in your close method to SaveChanges:=True (e.g., oDoc.Close SaveChanges:=True). This ensures all modifications made by your script are saved before the document is closed.




