VBA & Macro Problems

Use Excel VBA to Access Files Stored in SharePoint Online

Jason MillerJason Miller Nov 2, 2026 869 views

Question details

The user needs to configure Excel macros to read from and write to Access and Excel files hosted on SharePoint Online instead of relying on local Windows file paths.

How to Use Excel VBA with Files Stored in SharePoint Online
Product
Microsoft Excel, SharePoint Online
Device & OS
not provided
Scenario
Automating data read/write processes across Excel and Access files that have been migrated to a cloud-based SharePoint Online environment.
Observed behavior
Existing macros depend on local Windows paths and fail or require updating to properly handle SharePoint Online URLs for data operations.
Before you start

Ensure you have the appropriate site permissions to access the SharePoint Online files and that you are logged into Excel with your organizational Microsoft account.

Solution 1Recommended

Access SharePoint Files via Direct URL Path

Obtain the direct web path of the SharePoint file to pull data directly into Excel without writing complex API authentication code.

This method is ideal for directly referencing a specific workbook or dataset stored in SharePoint. By tweaking the URL provided by the Excel desktop app, you can seamlessly connect to cloud files using standard data connections.

1
Open the SharePoint File

Navigate to SharePoint and open the target Excel file in the Excel desktop application.

2
Copy the File Path

Click on 'File' in the top-left corner, select 'Info', and click the 'Copy Path' button to copy the file's web URL.

3
Format the URL

Paste the copied URL into a text editor. Locate the '?web=1' suffix at the very end of the link and delete it, leaving just the raw file path.

4
Connect the Data

In your working Excel file, go to 'Data' > 'Get Data' > 'From Web'. Paste the modified URL into the dialog box and authenticate using your organizational account when prompted.

Access SharePoint Files via Direct URL Path
URL Formatting: Removing '?web=1' forces Excel to recognize the link as a direct data file rather than a web browser view.
Free Microsoft Office alternative

Need a Lightweight, Macro-Enabled Alternative to Microsoft Office?

While highly specific cloud integrations like SharePoint REST APIs rely heavily on the Microsoft ecosystem, everyday data automation doesn't have to be complicated. WPS Office offers a powerful, lightweight alternative with robust macro support and excellent format compatibility.

Fully compatible with Microsoft Excel formats (.xlsx, .xls) and standard VBA macros.Free to use with a familiar, tabbed interface that requires zero learning curve.Lightweight installation that runs smoothly even on older Windows computers.Built-in cloud storage options for easy file backup and cross-device sharing.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my copied SharePoint file path end with '?web=1'?

The '?web=1' parameter tells your system to open the document in the Excel web application inside a browser. Removing it allows Excel VBA and Power Query to target the actual underlying file for data extraction.

Can I use synced local mapped drives instead of SharePoint URLs in VBA?

Yes, you can sync SharePoint libraries to a local folder using OneDrive and use standard local Windows file paths in your VBA code. However, this method may break if you share the macro with other users whose OneDrive sync paths (like C:\Users\[Username]\...) differ from yours.

How do I authenticate SharePoint REST API calls in Excel VBA?

Authenticating REST APIs in VBA usually involves registering an application in Microsoft Entra ID (Azure AD) to acquire an OAuth 2.0 access token. This token is then passed in the header of your VBA XMLHTTP requests as a 'Bearer' token.

Does WPS Office support VBA macros?

Yes, WPS Office provides excellent support for VBA macros. You can run, edit, and create VBA scripts seamlessly in WPS Spreadsheets, making it a great alternative for macro-driven workflows.