VBA & Macro Problems

Fix Word VBA Error 5941 When Activating a Document from Access

Olivia MillerOlivia Miller Nov 14, 2026 869 views

Question details

Fix an Access VBA routine that opens Word documents but fails when activating a document window.

Fix Word VBA Error 5941 When Activating a Document from Access
Product
Microsoft Access and Microsoft Word VBA
Device & OS
not provided
Scenario
An Access macro opens Word documents, copies their contents, and pastes them into a destination document.
Observed behavior
Documents open successfully, but activating a window by its full path and Compatibility Mode caption causes Runtime Error 5941 on some computers.
Before you start

Open the Access VBA editor and locate the code that opens and activates the Word document. Identify the Word Application object, source file path, and destination document used by the routine.

Solution 1Recommended

Store Word document references instead of matching window captions

Use this approach to avoid caption differences and work directly with the documents opened by Access.

Word window captions can vary by version and may or may not include Compatibility Mode. A saved Document object avoids depending on that caption or on whichever document is currently active.

1
Declare document variables

In the Access VBA editor, add `Dim sourceDoc As Object` and `Dim destDoc As Object` to the routine. This example uses late-bound object variables.

2
Save the destination reference

Before opening a source file, save the intended destination document in `destDoc`. For example, if it is currently active in the existing Word Application object `wordApp`, use `Set destDoc = wordApp.ActiveDocument`.

3
Capture the opened document

Replace the open-and-activate sequence with `Set sourceDoc = wordApp.Documents.Open(filePath)`, using the routine's existing Word Application object and source file path.

4
Copy and paste using the references

Use `sourceDoc.Content.Copy` to copy the source, then use `destDoc.Range(destDoc.Content.End - 1, destDoc.Content.End - 1).Paste` to paste at the end of the destination. Repeat with a new `sourceDoc` reference for each file.

5
Activate only if needed

Remove the window-caption activation call. If a later operation requires the source document to be active, use `sourceDoc.Activate` instead.

Store Word document references instead of matching window captions
Check the intended paste location: The example pastes at the end of the destination document. If your routine needs another location, use the appropriate destination range instead.
Free Microsoft Office alternative

Work with Word documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Office files. It can help you move everyday document work to WPS, but it does not fix Microsoft Access-to-Word VBA activation errors.

Open and edit documents with a familiar word-processing interfaceCompatible with Microsoft Word DOC and DOCX formatsCopy and paste content between documents without an activation macroFree, lightweight office tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does the activation code work on one computer but not another?

Word versions can display different window captions, including whether they append Compatibility Mode. Replace the exact caption lookup with the Document object returned by `Documents.Open`.

Does opening a Word document automatically make it active?

The most recently opened document is normally active, so a separate activation may not be necessary. Store the result of `wordApp.Documents.Open(filePath)` and use that reference for subsequent operations.

Is Error 5941 necessarily caused by permissions?

No. In this scenario, a missing or mismatched document or window reference is a more likely cause. Check the reference and caption used by the activation call before assuming it is a permissions issue.

How can I return to the destination document without relying on ActiveDocument?

Save the destination as a Document object before opening the source. Then use that reference, such as `destDoc.Range(...).Paste`, or call `destDoc.Activate` if activation is required.