Fix an HTTP 403 Error in Excel VBA XMLHttpRequest
Question details
Identify why an Excel VBA XMLHttpRequest receives HTTP 403 in Microsoft 365 when the code previously worked in Office 2007.

- Product
- Microsoft Excel for Microsoft 365
- Device & OS
- not provided
- Scenario
- A VBA macro sends an HTTP request to a website or service after an upgrade from Office 2007.
- Observed behavior
- The request returns HTTP 403, indicating that the server is refusing access.
Identify the request URL and confirm that the service permits automated access. Have the service's current API or authentication documentation available, and avoid sharing credentials or tokens when reporting the error.
Inspect the 403 response and current request requirements
Use this approach to identify whether the server is rejecting the request because its access or authentication requirements have changed.
HTTP 403 means the server understood the request but is refusing it. Possible causes include changed permissions, missing authentication, required cookies or CSRF tokens, rate limits, or automated-access restrictions.
Open the VBA editor with Alt+F11 and locate the XMLHttpRequest code. After the request completes, inspect the request object's Status and ResponseText properties in the Immediate window or with Debug.Print.
Sign in through the service's normal browser interface, open the browser's developer tools, and use the Network tab to inspect the relevant request. Compare its URL, method, and documented authentication requirements with the VBA request.
Open the service's documentation or account permissions page and check whether the endpoint requires an API token, a session, a CSRF token, or a specific User-Agent, and whether automated requests are allowed.
Update the VBA request using the service's documented authentication and headers, then run the macro again. If access is restricted or the response indicates a rate limit, contact the service provider or follow its published limits.

Switch the VBA request to an official API
Use the service's supported API when its website endpoint no longer permits the macro's request.
Work with Excel Spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility for an easier transition. It does not resolve a server-side HTTP 403 or guarantee compatibility with every Excel VBA macro.

Frequently Asked Questions
Does HTTP 403 mean my Excel VBA syntax is wrong?
Not necessarily. HTTP 403 is a response from the server refusing the request. Check the XMLHttpRequest object's Status and ResponseText, then review the service's permissions and authentication requirements.
Why did the request work in Office 2007 but fail in Microsoft 365?
The service's authentication, endpoint, rate limits, or automated-access rules may have changed since the macro was written. Compare the VBA request with the service's current documentation rather than assuming the Office upgrade is the only cause.
Can changing the User-Agent fix a 403 error?
A service may require a particular User-Agent, but changing it is not a general fix. Check the provider's documentation and use only permitted request headers; do not use a User-Agent to evade access restrictions.
What should I do if the website blocks automated requests?
Check the provider's developer documentation for an official API or contact the provider for authorized access. Do not bypass the website's bot protection or other access controls.




