How to Use Excel Macros with OneDrive and Excel for the Web
Question details
The user needs to know how to execute VBA macros in an Excel workbook that is saved on OneDrive and accessed via Excel for the web.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Attempting to run automated VBA scripts on a cloud-stored workbook using the web-based version of Excel.
- Observed behavior
- Excel for the web can open and edit the workbook but lacks the functionality to run or edit VBA macros directly in the browser.
Ensure that you have the Microsoft Excel desktop application installed on your computer, as VBA macros cannot be executed directly within a web browser environment.
Open the Workbook in the Excel Desktop App
Since Excel for the web does not support VBA execution, you must transition your session to the desktop application to run your macros while keeping the file synced to OneDrive.
Excel for the web is designed for lightweight editing and collaboration. To utilize advanced features like VBA macros, Microsoft provides a seamless transition button to open your cloud file in the full desktop software.
Any changes made or macros executed in the desktop app will automatically synchronize back to your OneDrive file, ensuring your data stays up to date in the cloud.
Navigate to your OneDrive account in your web browser and click on your macro-enabled workbook (.xlsm) to open it in Excel for the web.
Look at the ribbon menu at the top of the browser window. Click the 'Viewing' or 'Editing' button, then select 'Open in Desktop App' from the drop-down menu.
Once the workbook opens in your local Excel application, click 'Enable Content' in the security warning bar at the top, then run your VBA macros as you normally would.

Use WPS Office to Run VBA Macros Seamlessly
If you frequently work with macro-enabled workbooks and need a reliable, lightweight desktop solution, WPS Office provides excellent VBA support. It serves as a powerful, free alternative to Microsoft Office that handles .xlsm files perfectly.
- 1. Download and Install WPS Office: Visit the official WPS website to download and install the free WPS Office suite on your computer.
- 2. Open WPS Spreadsheet: Launch WPS Spreadsheet, which serves as a highly compatible desktop alternative to Microsoft Excel.
- 3. Run Your Macros: Open your macro-enabled workbook (.xlsm) in WPS Office, enable macros when prompted by the security warning, and run your VBA scripts seamlessly.

Frequently Asked Questions
Can I edit the data in a macro-enabled workbook using Excel for the web?
Yes, Excel for the web allows you to open and edit the standard cell data within a macro-enabled workbook (.xlsm). However, you cannot run, edit, or view the actual VBA code while in the browser.
Why did my macros disappear when I saved my file in Excel for the web?
If you use 'Save As' and choose the standard Excel Workbook (.xlsx) format instead of a Macro-Enabled Workbook (.xlsm), all VBA code will be stripped from the file. Always ensure you are working with and saving in the correct .xlsm format.
Can Office Scripts replace my VBA macros on the web?
Office Scripts is a modern, cloud-based scripting language designed specifically for Excel for the web. While it cannot directly run your legacy VBA code, you can rewrite simple automation tasks using Office Scripts for pure web-based execution.




