Skip to content

What are Office Scripts?

Office Scripts are a scripting feature for automating tasks in Excel.

They were originally available only in Excel on the web, but you can now also use them in Excel for Windows (version 2210 or later) and Excel for Mac.

They play a role similar to VBA macros in desktop Excel.

You write scripts in TypeScript. The syntax is very different from VBA, but if you’re familiar with Google Apps Script, which is also based on JavaScript, you’ll find them easy to work with.

This chapter explains how to use Office Scripts with sample code, and points out how they differ from VBA along the way.

This site provides samples like the following.

Sample format
function main(workbook: ExcelScript.Workbook) {
const fruits: string[] = [];
fruits.push('Apple', 'Orange', 'Banana');
const labels = fruits.map<string>((fruit, i) => {
return `Fruit #${i + 1} is ${fruit}`;
});
}