Excel Error Codes

Fix an HTTP 403 Error in Excel VBA XMLHttpRequest

Camila MilosovichCamila Milosovich Nov 18, 2026 870 views

Question details

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

Fix an HTTP 403 Error in Excel VBA XMLHttpRequest
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.
Before you start

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.

Solution 1Recommended

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.

1
Inspect the response

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.

2
Compare an authorized browser request

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.

3
Check service requirements

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.

4
Correct and retest

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.

Inspect the 403 response and current request requirements
Do not bypass access controls: Do not attempt to evade bot protection or other restrictions. Browser access alone does not mean automated access is permitted.
Free Microsoft Office alternative

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.

Open and edit spreadsheets in a familiar interfaceWork with Microsoft Excel formats including XLSX and XLSUse a free, lightweight alternative for everyday spreadsheet tasksReview spreadsheet data while troubleshooting an external service request
microsoft office alternative - wps office

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.