VBA & Macro Problems

How to Fix Excel Macros Not Working After Moving to SharePoint

Amos GikundaAmos Gikunda Oct 29, 2026 870 views

Question details

Excel macros fail to execute after migrating workbooks from a local server to SharePoint Online.

How to Fix Excel Macros Not Working After Moving to SharePoint
Product
Microsoft Excel
Device & OS
not provided
Scenario
Users are migrating their macro-enabled Excel workbooks from a local file server to SharePoint Online.
Observed behavior
Macros that functioned correctly on the local server now fail when run from the Microsoft 365 desktop app, though they may work through local OneDrive synchronization.
Before you start

Ensure you have the exact SharePoint URL or the new synced OneDrive folder path ready before modifying your VBA code.

Solution 1Recommended

Update the Hardcoded VBA File Paths

Modify your macro code to reference the new SharePoint location or the local OneDrive sync folder instead of the old server.

When files are moved from a local server to SharePoint Online, their absolute file paths change. If your VBA macros rely on hardcoded local paths (e.g., an old drive letter or network path), Excel will be unable to locate the required data, causing the macro to fail.

1
Launch the VBA Editor

Open the affected workbook in the Microsoft Excel desktop app and press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) Editor.

2
Locate the Old Path

Use the search function (Ctrl + F) within the editor to find references to the old local server path in your macro modules.

3
Replace with the New Path

Delete the outdated local path and insert the correct SharePoint Online URL or your local OneDrive sync folder path (e.g., C:\Users\[Username]\SharePoint...).

4
Save and Test the Macro

Click the 'Save' icon in the VBA Editor, close the window, and try running your macro again to ensure it successfully locates the files.

Update the Hardcoded VBA File Paths
Pro Tip: Use Dynamic Paths: To prevent this issue in the future, consider using 'ThisWorkbook.Path' in your VBA code instead of absolute paths, allowing the macro to dynamically locate files stored in the same directory.
Free Microsoft Office alternative

Try WPS Office for a Smoother Spreadsheet Experience

If complex Microsoft Excel macro path issues and SharePoint configurations are slowing down your workflow, consider trying WPS Office. It is a lightweight, highly compatible, and free alternative designed to make managing spreadsheets simple and efficient.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free software for your operating system.
  2. 2. Install WPS Office: Run the installer file and follow the quick on-screen instructions to set up the software.
  3. 3. Open Your Workbooks: Launch WPS Spreadsheet and open your existing Excel files directly with perfect formatting preservation.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .xlsm)Lightweight application with exceptionally fast processing speedsFamiliar user interface ensuring zero learning curve for seamless migrationEfficient handling of both local files and cloud-synced documents
microsoft office alternative - wps office

Frequently Asked Questions

Why do my macros work locally but fail on SharePoint?

Macros often rely on absolute file paths hardcoded into the VBA scripts. When the file is moved to SharePoint, the macro continues to look for the old local server path unless manually updated.

Can VBA handle HTTPS SharePoint URLs directly?

While VBA can process HTTPS paths to an extent, certain older macro functions or specific file system object commands (like Dir) require traditional file paths. In these cases, using a locally synced OneDrive folder path is recommended.

How can I prevent path errors when multiple users access the file?

You can modify your VBA code to use relative paths, such as using 'ThisWorkbook.Path', which dynamically determines the location of the active workbook regardless of which user's synced folder it is running from.