FormulaCamp
Completed
14. Office Scripts and Power Automate · Introduction · 15 min

1. Office Scripts and Power Automate

Lesson 1 of 6
    Lesson theory

    Office Scripts automate Excel with TypeScript. Scripts are stored in the cloud (OneDrive) and run in Excel for the web, and with a suitable Microsoft 365 license, in desktop Excel too. On the Automate tab, Record Actions turns your clicks into a draft script, and the Code Editor lets you edit it.

    function main(workbook: ExcelScript.Workbook) {
      const sheet = workbook.getActiveWorksheet();
      sheet.getRange("B11").setFormula("=SUM(B2:B10)");
      sheet.getRange("A1:D1").getFormat().getFont().setBold(true);
    }

    Power Automate runs scripts on a schedule or when something happens: "every Monday at 9:00 AM, process the sales file and email the report."

    Compared with VBA: TypeScript instead of Basic, it works on the web, and it connects easily to cloud flows. On the other hand, there are no UserForms and no access to files on your computer.

    Test yourself

    1. What language are Office Scripts written in?
    2. How do you run a script automatically on a schedule?
    3. What does every Office Script start with?