Browse all topics

Office Scripts in Excel

Office Scripts is Microsoft's modern automation language for Excel — what it does, where it runs, and how it compares to VBA.

Office Scripts is Microsoft's modern automation language for Excel — TypeScript-based, web-first, and integrated with Power Automate. It's the cloud-era replacement for the long-running but Windows-only VBA macros, and it's where Microsoft is investing for Excel automation.

What Office Scripts can do

Inside Excel on the web (and increasingly on Windows / Mac):

  • Record and replay actions — like macros, but in TypeScript that's editable and shareable.
  • Automate workbook tasks — formatting, formulas, chart creation, table operations, sorting, filtering.
  • Parameterise scripts — define parameters so a script accepts inputs at run time.
  • Call scripts from Power Automate flows — trigger script execution as part of a larger workflow.

Scripts run in the cloud against the workbook's cloud copy. No installation, no local execution context.

The language

Office Scripts uses a small TypeScript subset with a specific Excel object model:

function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  const range = sheet.getRange("A1:C10");
  range.setValues([
    ["Name", "Score", "Status"],
    // ...
  ]);
}

The object model — Workbook, Worksheet, Range, Table, Chart — is similar in concept to VBA's but rebuilt for the web. The TypeScript editor in Excel for the web provides IntelliSense.

Compared to VBA

| Aspect | VBA | Office Scripts | | --- | --- | --- | | Runs in | Windows desktop Excel | Excel web (and increasingly desktop) | | Language | Visual Basic | TypeScript | | File location | Embedded in .xlsm | Stored in the user's OneDrive | | Sharing | Email the file | Share scripts independently | | Distribution | Local install | Tenant-wide via admin | | Power Automate integration | Limited | Native | | Best for | Legacy automation, complex desktop scenarios | New automation, multi-user scenarios, Power Automate flows |

VBA isn't going away in the near term, but new Excel automation should start in Office Scripts.

Power Automate integration

The most powerful pattern is flow + script:

  • A scheduled Power Automate flow opens a workbook in OneDrive or SharePoint.
  • The flow calls an Office Script that pulls fresh data, formats a report, generates charts.
  • The flow emails the workbook to stakeholders or posts it to Teams.

This replaces a lot of the "Excel as a reporting engine" patterns that previously needed a desktop bot.

Admin and governance

Office Scripts is enabled per tenant in the Microsoft 365 admin center. Tenant admins can scope script creation to specific users (typically a "scripters" group), control script sharing, and audit script execution via Purview audit logs.

For organisations using Excel as a workflow tool — finance, operations, supply chain — Office Scripts is the single most valuable new Excel feature in years.