logo
search
VBA & Macro Problems

Fix Excel Macro Saving JSON File to Unexpected OneDrive Path (d.docs.live.net)

Bushra ParveenBushra Parveen Oct 7, 2026 868 views

Question details

The user's Excel macro generates a JSON file but saves it to a OneDrive web URL instead of the expected local desktop or folder path.

How to Fix Excel Macro Saving JSON File to Unexpected OneDrive Path
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro designed to export workbook data and save it as a local JSON file.
Observed behavior
The macro successfully executes but reports saving the file to an address starting with https://d.docs.live.net, making the file difficult to locate locally.
Before you start

Ensure you have access to the VBA Editor by pressing ALT + F11, and check if your current Excel workbook is stored in a synced OneDrive folder.

Solution 1Recommended

Update the Hard-Coded Macro Path to a Local Directory

Change the save path in your VBA code to force Excel to save the JSON file to a specific local folder, bypassing OneDrive's cloud URL.

When an Excel workbook is saved in a OneDrive folder, using properties like 'ThisWorkbook.Path' in VBA returns the cloud URL (https://d.docs.live.net...) instead of the local C: drive path. To fix this, you must explicitly define a local path in your macro.

1
Open the VBA Editor

In Excel, press ALT + F11 to open the Microsoft Visual Basic for Applications (VBA) Editor.

2
Locate the Save Code

In the Project Explorer panel, find the module containing your JSON export code and double-click to open it.

3
Define a Local Path

Find the line of code that sets the file save path. Replace any dynamic path variables (like ThisWorkbook.Path) with a direct local string, for example: strFilePath = "C:\Users\YourUsername\Documents\output.json"

4
Run and Verify

Save your VBA changes, run the macro again, and check the designated local folder to confirm the .json file was created successfully.

Update the Hard-Coded Macro Path to a Local Directory
Dynamic Local Paths: If you need the macro to work on different computers, use Environ("USERPROFILE") & "\Documents\output.json" to dynamically generate a local path.
Free Microsoft Office alternative

Try WPS Office for Hassle-Free Macro Execution

Avoid confusing OneDrive sync paths with WPS Office. WPS Spreadsheet offers excellent VBA compatibility, allowing you to run your macros and save files locally by default without unexpected cloud routing. It's a lightweight, free alternative to Microsoft Excel.

  1. 1. Download WPS Office: Install WPS Office Free on your computer.
  2. 2. Open Your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm file.
  3. 3. Run Macros Locally: Execute your VBA macros and enjoy predictable, local file saving without forced cloud synchronization.
Highly compatible with Microsoft Excel (.xlsx, .xlsm, .csv) and VBA macros.Saves files to your local drive by default, avoiding unexpected d.docs.live.net cloud URLs.Free, lightweight, and fast to install on any device.Familiar tabbed interface makes migrating from Microsoft Office seamless.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Excel macro path show d.docs.live.net?

When your Excel workbook is saved in a folder synchronized by OneDrive, Microsoft Excel treats the active path as a web URL (d.docs.live.net) rather than a local file path. Any macro using 'ThisWorkbook.Path' will output this cloud address.

Can changing Excel AutoSave settings fix the macro path?

No. Changing your Excel AutoSave settings will not correct a path that is defined or derived in the VBA macro. You must either move the workbook out of the OneDrive folder or explicitly code a local directory path in the macro.

How do I know if the JSON file was actually created?

If the macro runs without throwing an error and returns a d.docs.live.net URL, the file was successfully created in the cloud. You can find it by logging into OneDrive via a web browser or by checking your local OneDrive sync folder.