Differences between Office Scripts and VBA macros

Office Scripts and VBA macros have a lot in common. They both allow users to automate solutions through an easy-to-use action recorder and allow edits of those recordings. Both frameworks are designed to empower people who may not consider themselves programmers to create small programs in Excel.

The fundamental difference is that VBA macros are developed for desktop solutions and Office Scripts are designed for secure, cross-platform, cloud-based solutions.

A four-quadrant diagram showing the areas of focus for different Office extensibility solutions. Both Office Scripts and VBA macros are designed to help end users create solutions. Office Scripts are built for cross-platform experiences and collaboration, whereas VBA is for the desktop.

This article describes the main differences between VBA macros (as well as VBA in general) and Office Scripts. Since Office Scripts are only available for Excel, that is the only host being discussed here.

Platform and ecosystem

The following table shows which features are supported by which platforms and products.

Excel on the web Excel for Windows Excel for Mac Excel for iOS Other Office products Power Automate
Office Scripts Yes Yes Yes No No Yes
Office Scripts Action Recorder Yes Yes Yes No No No
VBA macros No Yes Yes No Yes No
Office Add-ins Yes Yes Yes Yes Yes No
COM Add-ins No Yes Yes No Yes No

VBA is designed to be desktop-centric. VBA can interact with a user's desktop to connect with similar technologies, such as COM and OLE. However, VBA has no convenient way to call out to the internet. Office Scripts use a universal runtime for JavaScript. This gives consistent behavior and accessibility, regardless of the machine being used to run the script. They can also make calls to a limited set of web services.

Users require an enterprise or educational license to use or create Office Scripts. For the full list of supported licenses, see Platform support. VBA is built-in to the desktop versions of Excel and requires no special licensing.

Security

VBA macros have the same security clearance as Excel. This gives them full access to your desktop. Office Scripts only have access to the workbook, not the machine hosting the workbook. Additionally, no JavaScript authentication tokens can be shared with scripts. This means the script has neither the tokens of the signed-in user nor are there any API capabilities for signing in to an external service, so they are unable to use existing tokens to make external calls on behalf of the user.

Admins have three options for VBA macros: allow all macros on the tenant, allow no macros on the tenant, or allow only macros with signed certificates. This lack of granularity makes it hard to isolate a single bad actor. Currently, Office Scripts can be off for an entire tenant, on for an entire tenant, or on for a group of users in a tenant. Admins also have control over who can share scripts with others and who can use scripts in Power Automate.

Coverage

Currently, VBA offers a more complete coverage of Excel features, particularly those available on the desktop client. Office Scripts cover nearly all of the scenarios for Excel on the web. Additionally, as new features debut on the web, Office Scripts will support them for both the Action Recorder and JavaScript APIs.

Office Scripts don't support Excel-level events. Scripts are only run when a user manually starts them or when a Power Automate flow calls the script.

Power Automate

VBA doesn't have a Power Automate connector. All supported VBA scenarios involve a user attending to the macro's execution.

Office Scripts can be run through Power Automate. Your workbook can be updated through scheduled or event-driven flows, letting you automate workflows without even opening Excel. Try Tutorial: Update a spreadsheet from a Power Automate flow to start learning about Power Automate. You can also check out the Automated task reminders sample to see Office Scripts connected to Teams through Power Automate in a real-world scenario.

See also