Fix VBA HTTP Responses Mixed Between Concurrent Users in Word
Question details
Concurrent users executing a Word VBA macro receive mixed HTTP responses, resulting in one user receiving data intended for another.

- Product
- Word VBA
- Device & OS
- not provided
- Scenario
- Executing a Word VBA macro that sends HTTP POST requests to a backend server using MSXML2.XMLHTTP.6.0 simultaneously across multiple computers.
- Observed behavior
- While individual requests return correct data, simultaneous macro executions on different computers result in users receiving HTTP response data intended for another concurrent user.
Ensure you have access to the VBA macro source code in the Developer tab and administrative access to the server-side application logs to trace where the data mix-up occurs.
Isolate the MSXML2.XMLHTTP Object in VBA
Prevent session and variable sharing by ensuring each HTTP request generates a unique, locally-scoped unshared object.
If the HTTP object is declared globally or not properly re-instantiated, VBA or the underlying Windows internet layer (WinINET) might reuse sessions or cache, causing concurrent requests to bleed together.
Press ALT + F11 in Word to open the Visual Basic for Applications Editor, then locate the module containing the POST request script.
Ensure that your MSXML2.XMLHTTP.6.0 object is declared within the specific function or subroutine, not at the module level (e.g., use Dim xmlHttp As Object directly inside your Sub).
Before making the request, explicitly create a new instance using Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0"). Do not reuse old objects for new POST requests.
Add a unique timestamp or GUID as a query string parameter to your request URL (e.g., "url?t=" & Timer) to force a fresh request and bypass any local network or proxy caching.

Verify Thread Safety in the Server Application
Ensure the Java servlet or backend handling the POST request does not use shared mutable state for user data.
Implement Unique Request Identifiers for Tracing
Use unique IDs sent from the client to pinpoint exactly where the response data crosses over between users in the server logs.
Need a Reliable Environment for Macros? Try WPS Office
WPS Office is a highly compatible, fast, and lightweight office suite. It offers robust support for VBA and Macros, allowing you to run your enterprise scripts seamlessly while enjoying a modern, tabbed interface.
- 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install the Suite: Run the setup file and follow the on-screen prompts to complete the lightweight installation.
- 3. Enable Macros: Open WPS Office, navigate to the Developer tab, and enable Macro support to run your existing VBA scripts.

Frequently Asked Questions
Why does MSXML2.XMLHTTP.6.0 cache responses in VBA?
By default, XMLHTTP relies on the underlying Windows Internet (WinINET) layer, which caches responses based on standard IE settings to save bandwidth. To prevent this, you can set the `Cache-Control` header to `no-cache` or append a random timestamp parameter to your request URL.
Can using ServerXMLHTTP instead of XMLHTTP solve concurrency issues?
Yes. `MSXML2.ServerXMLHTTP` is designed for server-safe, concurrent HTTP requests. It bypasses URLmon and WinINET, ignoring standard browser proxy and cache settings, which can often resolve caching and session bleed issues in VBA clients.
How do I know if my backend Java servlet is thread-safe?
A Java servlet is considered thread-safe if it avoids using instance variables (class-level fields) to store request-specific data. Since the server handles concurrent requests using multiple threads on the same servlet instance, all user-specific data must be declared locally within the execution methods like `doGet` or `doPost`.




