VBA & Macro Problems

How to Retrieve URL Text with Office Scripts in Excel

Chanuka GeekiyanageChanuka Geekiyanage Oct 28, 2026 869 views

Question details

The user needs to retrieve text from a URL using JavaScript fetch requests within Excel Office Scripts but is encountering errors or output issues.

Product
Microsoft Excel
Device & OS
not provided
Scenario
Automating data retrieval from web URLs using Office Scripts (JavaScript) in Excel.
Observed behavior
The script fails to fetch the URL text correctly, or the console output does not display the expected results.
Before you start

Ensure you have an active internet connection and that your Microsoft 365 subscription includes access to Office Scripts. Check if the URL you are trying to fetch has CORS (Cross-Origin Resource Sharing) restrictions that might block the request.

Solution 1Recommended

Consult the Official Office Scripts Developer Community

Since Office Scripts involves custom JavaScript/TypeScript coding, the dedicated Microsoft developer community is the best place to resolve complex fetch request errors.

Office Scripts execute in a specific cloud environment, meaning standard JavaScript fetch requests might behave differently due to CORS policies or network restrictions. Microsoft engineers actively monitor their dedicated forums to help with these specific API issues.

1
Gather your code and error logs

Copy the exact JavaScript/TypeScript code you are using for the fetch request and any error messages displayed in the Code Editor console.

2
Visit the developer community

Navigate to the Microsoft Tech Community or the Microsoft Q&A platform and select the 'Office Scripts' tag.

3
Post your question

Create a new thread, paste your code snippet, describe the URL you are trying to reach, and explain the troubleshooting steps you have already taken.

Consult the Official Office Scripts Developer Community
Provide Context: Always redact any sensitive API keys or personal data from your URLs and code before posting in public forums.
Free Microsoft Office alternative

Try WPS Office for Your Spreadsheet and Macro Needs

If you are experiencing ongoing issues with Microsoft Office Scripts or simply need a powerful, lightweight, and free alternative, WPS Office is an excellent choice. It offers robust spreadsheet capabilities, seamless compatibility with Microsoft Excel files, and its own macro tools to automate your workflow without the heavy subscription costs.

Fully compatible with Microsoft Excel formats (.xlsx, .xls, .csv).Includes an advanced Spreadsheet application for complex data analysis.Supports JS Macros to automate repetitive tasks efficiently.Lightweight and free to use, saving you subscription fees.Familiar user interface for a seamless transition from Microsoft Office.
QA img-9

Frequently Asked Questions

Can I use VBA instead of Office Scripts to fetch URL text?

Yes, in desktop versions of Excel, you can use VBA with the 'MSXML2.XMLHTTP' object to send HTTP requests and retrieve text from URLs. However, VBA does not work in Excel on the web.

Why does my fetch request return a CORS error?

CORS (Cross-Origin Resource Sharing) is a security feature. If the server hosting the URL does not explicitly allow requests from the Office Scripts environment, the browser will block the fetch request.

Does WPS Office support JavaScript macros?

Yes, WPS Office supports WPS Macro (based on JavaScript/TypeScript), allowing you to write scripts to automate tasks and interact with spreadsheet data much like Office Scripts.

Where can I view the console output in Excel Office Scripts?

You can view the console output by opening the Code Editor pane in Excel, running your script, and checking the 'Output' or 'Console' tab at the bottom of the editor.