Why Excel VBA Macros Do Not Work in SharePoint or Excel for the Web
Question details
The user is unable to run VBA macros when opening Excel workbooks through SharePoint browser views or Excel for the Web.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Attempting to execute VBA code, automate tasks, or use features like active-row highlighting while viewing or editing a spreadsheet in a web browser.
- Observed behavior
- The VBA macros do not run, and the browser-based version of Excel indicates that macros are unsupported.
Ensure you have a desktop spreadsheet application installed on your computer, as browser-based environments do not contain the runtime engine required to execute VBA code.
Open the Workbook in the Excel Desktop Application
The most effective way to use VBA macros stored in SharePoint is to launch the file directly in your local desktop application.
VBA (Visual Basic for Applications) relies on local system architecture and Windows-based components that web browsers cannot access. To use your automated scripts, the file must be routed from the web interface to the desktop client.
Navigate to your SharePoint document library and open the macro-enabled workbook (.xlsm) in Excel for the Web.
Look for the 'Viewing' or 'Editing' dropdown menu near the center or right side of the top ribbon.
Click on 'Open in Desktop App'. When prompted by your web browser, confirm that you want to open Microsoft Excel.
Once the file opens in the desktop application, click 'Enable Content' in the yellow security warning bar to allow your VBA macros to run normally.

Migrate VBA Macros to Office Scripts
If you need to automate workflows exclusively within the browser view, consider rewriting your VBA macros as Office Scripts.
Use WPS Office Desktop for Reliable Macro Execution
Since Excel for the Web does not support VBA macros, switching to a capable desktop suite is a practical solution. WPS Office is a lightweight, highly compatible alternative that natively handles standard Office files and allows you to run VBA macros efficiently on your local machine.
- 1. Download WPS Office: Visit the official WPS website and install the free WPS Office suite on your local computer.
- 2. Open your macro-enabled workbook: Launch WPS Spreadsheet and open your .xlsm file that contains the automated scripts.
- 3. Execute your macros: Enable macros when prompted and run your automated tasks seamlessly without browser limitations.

Frequently Asked Questions
Why do my macros work on my desktop but not in SharePoint?
SharePoint relies on Excel for the Web to display workbooks in your browser. This web-based environment lacks the necessary Windows-based VBA runtime engine required to execute macro code.
Will saving a macro-enabled workbook to SharePoint delete the macros?
No, uploading or editing an .xlsm file in SharePoint or Excel for the Web will not delete your existing VBA code. The macros simply remain dormant and will function normally once you open the workbook again in a compatible desktop app.
Why is the 'Open in Desktop App' button missing in SharePoint?
This usually happens if your organization's SharePoint administrator has restricted the ability to open files in local client applications, or if the device you are using does not have a recognized desktop Office suite installed.




