Fix Excel Saving Tax XML Files to Unexpected OneDrive Paths
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.

- 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 modifying the macro code, ensure you have Developer tab access enabled in Excel and check if pausing OneDrive sync temporarily halts the issue.
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.
Open the affected Excel tax workbook. Press 'Alt + F11' or go to the Developer tab and click 'Visual Basic' to launch the VBA Editor.
In the Project Explorer on the left, find the module containing your XML export macro. Double-click to open the code.
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\'.
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.

Move the Workbook to an Unsynced Local Folder
Remove the tax workbook from OneDrive syncing entirely to force Excel to recognize its true local file path.
Roll Back the Microsoft 365 Update
If the issue started immediately after a recent update, temporarily reverting to a previous Office build can restore functionality.
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. Download WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Open Your Macro Workbook: Launch WPS Spreadsheets and open your .xlsm tax workbook.
- 3. Run the XML Export: Enable macros when prompted and run your export tool. WPS will seamlessly respect your local folder structure.

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.




