No, Excel macros do not run natively in SharePoint Online or OneDrive for Business when you open a workbook directly in the browser using Excel Web App or Excel Online. Macros only execute when the file is opened in the desktop version of Excel and saved back to SharePoint, or when using Excel on Windows/macOS with appropriate permissions.

Understanding the Core Limitation

SharePoint itself is a content management and collaboration platform, not a computational environment. When users upload an .xlsm (macro-enabled) file to SharePoint, the platform stores the file as-is—including any embedded VBA code—but does not provide the runtime engine needed to execute macros. Excel Online (the browser-based version) intentionally omits VBA support for security, performance, and cross-platform consistency reasons. This means that if you click on a macro-enabled workbook in SharePoint and choose to open it in the browser, any macros included in that file will not run—even if the file contains a button or shortcut tied to a macro. The workbook will open and display data, but the macro functionality will be disabled or grayed out.

How File Opening Paths Affect Macro Behavior

Whether a macro works depends entirely on how and where the file is opened. There are three primary scenarios:

  1. Open in Browser (Excel Online): Macros are disabled. Only static data and formatting appear. Any macro-related UI elements (e.g., ActiveX controls, command buttons) are nonfunctional.
  2. Open in Desktop Excel from SharePoint: If the user clicks Edit in Excel (or Open in Excel) from the SharePoint ribbon or file menu, the file is downloaded to a temporary location and opened in the installed desktop version of Excel (2010 or later). Here, macros run normally—assuming macro security settings allow them and the user has enabled content when prompted.
  3. Synced Files via OneDrive Sync Client: When a SharePoint library is synced to a local folder using the OneDrive sync client, opening the .xlsm file directly from the local folder (e.g., in File Explorer) launches Excel locally. Macros execute as expected, and any changes—including those made via macros—are synced back to SharePoint.

Enabling Macros: Permissions and Security Settings

Even when opening in desktop Excel, macros may not run without proper configuration. Two key layers control this:

  • Excel Trust Center Settings: Within Excel, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Users must select an option that allows macros to run (e.g., Disable all macros with notification, then click Enable Content when the warning bar appears). Never choose Enable all macros in production environments—it poses serious security risks.
  • SharePoint File-Level Security: SharePoint does not block macros at the storage level, but site administrators can restrict file types using PowerShell or admin policies. For example, administrators may disallow .xlsm uploads entirely to enforce safer practices. If uploads are blocked, users can only save as .xlsx, stripping macros permanently.

Common Problems and Why They Happen

Users frequently encounter frustration when macros appear to “disappear” after uploading to SharePoint. Here are the most frequent root causes:

  • Opening in browser by default: SharePoint often defaults to opening files in Excel Online unless the user explicitly chooses Edit in Excel. This is especially common in new browser sessions or on mobile devices, where Excel Online is the only option.
  • Macro security blocking execution: Even in desktop Excel, if the user never clicks Enable Content on the security warning bar, the macro remains inactive. The warning bar may be missed if the workbook opens minimized or off-screen.
  • Corrupted macro references: If a macro references local paths (e.g., C:\Users\John\Data\), it fails when opened from SharePoint—because the path no longer exists. Macros should use relative paths or SharePoint URLs instead.
  • ActiveX controls not rendering: Embedded ActiveX controls (e.g., combo boxes, scroll bars) appear as gray boxes in Excel Online and do not respond. They only work reliably in desktop Excel.

Alternatives When Macros Are Not Feasible

For teams needing automation but constrained by SharePoint’s limitations, consider these viable alternatives:

  • Power Automate + Excel: Build cloud workflows that trigger on Excel file changes—e.g., send an email when a row is added, or update a SharePoint list from Excel data. Power Automate integrates natively with SharePoint and OneDrive.
  • Power Apps + Excel as data source: Create custom forms and dashboards connected to Excel data stored in SharePoint. Power Apps supports logic and validation without VBA.
  • Excel Functions and Tables: Replace simple macros with built-in features like LET, XLOOKUP, dynamic arrays, and structured references. Many data transformations once done via macros can now be handled with formulas alone.
  • Excel Services (legacy on SharePoint Server 2016/2019): On-premises SharePoint Server environments *can* use Excel Services to render macro-free workbooks in the browser and provide data connections—but Excel Services never executes macros. This option is not available in SharePoint Online.

Cost and Licensing Considerations

Using macros in SharePoint does not require extra Microsoft licensing beyond what’s needed for Excel and SharePoint itself. However, leveraging alternatives like Power Automate or Power Apps does have licensing implications:

  • Power Automate: Requires a per-user or per-flow license for advanced features (e.g., approval flows, RPA). Basic flows on SharePoint may work with a free license, but with execution limits.
  • Power Apps: Canvas apps connected to SharePoint require a per-user or per-app license for premium connectors (e.g., SQL Server, Dataverse). Basic SharePoint list operations are supported in the free tier.
  • Desktop Excel: Included with Microsoft 365 Business Standard/Premium, or standalone Excel subscriptions. Users without Excel cannot open .xlsm files in desktop mode—only view in browser (without macros).

Safety and Best Practices

Because macros can execute arbitrary code, SharePoint administrators should enforce strict controls:

  • Disable macro uploads: Use SharePoint Admin Center > Settings > Files > Block uploading files that contain macros to prevent .xlsm files from entering the environment. This is often the safest default.
  • Require macro signing: In large organizations, require macros to be digitally signed by a trusted publisher. Excel will only enable signed macros unless explicitly overridden.
  • Audit macro usage: Use Microsoft 365 Defender or audit logs to track macro-enabled file access and modifications—especially important for financial or regulated data.
  • Train users on risks: Phishing attacks often use malicious Excel macros. Users should never enable macros from unknown or untrusted sources—even if the file is hosted in SharePoint.

Frequently Asked Questions

Can I use macros in Excel Online on mobile devices?

No. Excel Online on iOS and Android does not support macros or VBA at all. Even if you open a macro-enabled file, the macros will be unavailable. Mobile access is limited to viewing and basic editing (values, formulas, formatting).

Why did my macro stop working after uploading to SharePoint?

Most likely, you opened the file in Excel Online (browser), where macros are disabled. Or, you opened it in desktop Excel but did not click Enable Content when the security warning appeared. Another possibility: the macro relied on local file paths that no longer exist after syncing or downloading.

Is there a way to force SharePoint to always open Excel files in desktop mode?

Yes, but only at the tenant or site level. In SharePoint Admin Center, go to Policies > Sharing and set Default to Open in Browser to No. Alternatively, users can manually choose Open in Excel from the file menu each time. There is no per-file setting to override the default.

Do SharePoint libraries support .xlsm files at all?

Yes—SharePoint stores .xlsm files just like any other document. The limitation is not in uploading or storing them, but in executing their macros outside the desktop Excel environment. If macros are disabled at upload (via admin policy), only .xlsx files are accepted.

What happens if I save an .xlsm file as .xlsx after editing in Excel Online?

Any macro code is permanently removed during the save operation. Excel Online automatically converts the file to .xlsx format, which does not support macros. Once saved this way, the macros cannot be recovered unless you have a prior version or backup.

Can I use Power Automate to trigger macros in Excel Online?

No. Power Automate cannot execute VBA macros in Excel Online or any browser-based Excel session. However, Power Automate can manipulate data in Excel files stored in SharePoint using its Excel connector (e.g., adding rows, updating cells)—without needing macros.