VBA & Macro Problems

Fix Excel Saving Tax XML Files to Unexpected OneDrive Paths

Camila MilosovichCamila Milosovich Nov 2, 2026 868 views

Question details

The user needs to prevent an Excel tax workbook from saving its generated XML files to a OneDrive URL, forcing it to save locally.

How to Fix Excel Saving Tax XML Files to an Unexpected OneDrive Path
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro in an Excel tax workbook to generate and export XML files locally.
Observed behavior
Instead of saving to the local workbook folder, the macro saves the XML file to a OneDrive URL (e.g., d.docs.live.net) due to a recent Microsoft 365 update changing how paths are resolved.
Before you start

Before modifying the macro code, ensure you have Developer tab access enabled in Excel and check if pausing OneDrive sync temporarily halts the issue.

Solution 1Recommended

Update VBA Code with an Explicit Local Path

Modify the macro's save path from a relative path to a hard-coded local directory to bypass OneDrive's URL resolution.

When a workbook is synced with OneDrive, the VBA property 'ThisWorkbook.Path' often returns a web URL (like https://d.docs.live.net/...) instead of the local C: drive path. If the macro relies on this property to export the XML, it will fail to save locally.

By defining an explicit local path in the VBA editor, you force Excel to bypass the cloud path and save the file directly to your computer.

1
Open the VBA Editor

Open the affected Excel tax workbook. Press 'Alt + F11' or go to the Developer tab and click 'Visual Basic' to launch the VBA Editor.

2
Locate the Export Code

In the Project Explorer on the left, find the module containing your XML export macro. Double-click to open the code.

3
Modify the Path Variable

Locate the line of code determining the save path (often starting with 'ThisWorkbook.Path'). Change this to a hard-coded local string, such as 'C:\TaxExports\'.

4
Save and Test

Save your VBA changes, close the editor, and run the macro again to confirm the XML file is saved directly to your specified local folder.

Update VBA Code with an Explicit Local Path
Path Workaround: If you need the path to remain dynamic for different users, consider writing a custom VBA function that translates the OneDrive URL string back to the local 'C:\Users\[Username]\OneDrive' equivalent.
Free Microsoft Office alternative

Use WPS Office for Reliable VBA Macro Execution

If unexpected Microsoft 365 path resolution issues disrupt your workflow, consider using WPS Office. It handles local files securely without forcing cloud URL conversions, ensuring your VBA macros execute smoothly exactly as coded.

  1. 1. Download WPS Office: Download and install the free version of WPS Office from the official website.
  2. 2. Open Your Macro Workbook: Launch WPS Spreadsheets and open your .xlsm tax workbook.
  3. 3. Run the XML Export: Enable macros when prompted and run your export tool. WPS will seamlessly respect your local folder structure.
Fully compatible with Microsoft Excel formats (.xlsm, .xlsx)Robust built-in VBA and Macro supportReliable local file management without forced cloud syncingFree and lightweight Office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does ThisWorkbook.Path return a d.docs.live.net URL?

When an Excel file is saved in a folder synchronized by OneDrive, Office treats it as a cloud document. Consequently, VBA returns the cloud URL (SharePoint or OneDrive) instead of the local C: drive path.

Can I turn off OneDrive URL generation just for Excel?

There is no built-in Excel setting to disable this specifically for VBA. You must either alter your VBA code to convert the URL string to a local path, or move the file to a folder that OneDrive does not sync.

How can I map the OneDrive URL back to a local path in VBA?

You can use the 'Environ("OneDrive")' function in VBA to identify the local OneDrive directory, then replace the 'https://d.docs.live.net/...' portion of the path string with the local environment path using the 'Replace' function.

Will my Excel macros work if I switch to WPS Office?

Yes, WPS Office includes advanced VBA support and is highly compatible with standard Excel macros, allowing you to run your existing code without rewriting it.