How to Fix Excel VBA Cannot Open File Stored in OneDrive
Question details
The user needs to fix a VBA macro that fails to open an Excel workbook hosted on OneDrive via an HTTPS URL.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running a recorded VBA macro that uses the Workbooks.Open method with a OneDrive cloud URL (https://d.docs.live.net).
- Observed behavior
- The file initially opens in Microsoft Edge, but the macro fails or crashes when attempting to open the file again after the workbook has been closed.
Ensure that the OneDrive desktop client is installed and actively syncing your cloud files to your local hard drive.
Use the Synchronized Local File Path in VBA
Update your VBA code to reference the local OneDrive folder path instead of the cloud URL, as the Workbooks.Open method is designed for local drives.
When recording macros in Excel, the recorder often captures the cloud URL (https://d.docs.live.net) for files saved in OneDrive. However, using cloud URLs with the Workbooks.Open method can cause the system to route the request to a web browser or fail entirely when executed repeatedly.
Open Windows File Explorer and navigate to your local OneDrive folder where the target Excel workbook is stored.
Hold down the Shift key on your keyboard, right-click the Excel workbook, and select 'Copy as path' from the context menu to copy the local C: drive directory.
Open the Excel VBA Editor (Alt + F11), locate the module containing your recorded macro, and replace the HTTPS cloud URL in the Workbooks.Open statement with the local path you just copied.
Run Macros Smoothly with WPS Office
If you are tired of complex cloud path issues and macro errors in Microsoft Excel, consider switching to WPS Office. It provides robust, reliable support for VBA and macros without the URL resolution conflicts.
- 1. Download and Install WPS Office: Download the free WPS Office suite from the official website and install it on your computer.
- 2. Enable Macro Features: Open WPS Spreadsheet, navigate to the Developer tab, and ensure that VBA macros are enabled for your workspace.
- 3. Open Your XLSM Files: Directly open your existing macro-enabled Excel workbooks in WPS Office to continue your automated workflows without compatibility issues.

Frequently Asked Questions
Why does Workbooks.Open launch Microsoft Edge instead of opening the file in Excel?
When a VBA macro uses an HTTPS cloud URL (like d.docs.live.net), Windows may interpret the link as a web address rather than a local file, prompting the system's default web browser to handle the request.
How do I find the local path of my OneDrive file for my VBA code?
Open File Explorer, navigate to your synced OneDrive folder, locate your Excel file, hold the Shift key while right-clicking the file, and select 'Copy as path'. You can paste this directly into your VBA script.
Will fixing the path to a local drive prevent the file from syncing to OneDrive?
No. As long as the file is located within your designated local OneDrive folder, the OneDrive desktop client will continue to automatically sync any changes you make via the macro to the cloud.




