VBA macros have been around for decades, but the new kids on the macro block are Office scripts. These are macros that can run on the web version of Excel. They are written in Typescript, a subset of Javascript.
In my last post I got Copilot to write a VBA macro and an Office script to do the same task.
https://a4accounting.com.au/ai-excel-vba-and-office-scripts
In this post I wanted to take you through how to use the Office script code from the previous post.
function main(workbook: ExcelScript.Workbook) {
const chart = workbook.getActiveChart();
if (!chart) {
throw new Error("Please select a chart before running the script.");
}
chart.getSeries().forEach((series) => {
const labels = series.getDataLabels();
labels.setShowSeriesName(true);
labels.setShowValue(true);
labels.setSeparator("\n");
});
}
Copy the above code.
In Excel in the Automate ribbon tab click the New Script drop-down and choose Create in Code Editor. Note you can also record scripts, but they are just as limited as recorded VBA macros.

A new Office Scripts task pane opens on the right-hand side.

This contains generic code. Delete all the code. Paste in the new copied code.

Click the icon on the right of the name (Script 10 in the image above). This allows you to rename the script using a more descriptive name.

The green triangle allows you to run the code. You need to select a chart before running the code.
If you have closed the task pane and have a chart selected, the entries on the Automate ribbon are greyed out.

Select a cell and then click the script name you want to use.

When the task pane is open on the right, then select the chart and then run the script using the green triangle.

Office scripts do not yet cover as much functionality as VBA macros, but they do work on the web version of Excel.

Dear Neale, Thanks for the AI, Excel VBA and Office Scripts series. I checked my desktop excel app and did not find
Automate tab there. It seems from your post it is available only in the Excel web version.
Hi Sandeep
If you have the subscription version of Excel it should be available.
Check the tab hasn’t been hidden in Customise ribbon.