Office Scripts Tutorial: Automate a Weekly Excel Report

Video tutorial · 8:48 · Published

About this video

Write an Office Script that totals last week's sales by region, writes a formatted summary sheet and returns the figures to a scheduled Power Automate flow that emails them.

This tutorial walks through the steps of the full guide on screen; the chapters below jump to each part.

Chapters

  1. 0:00 What this video covers
  2. 0:17 Prepare the SalesData table
  3. 1:09 Open the Code Editor
  4. 1:40 Write main and read the table
  5. 2:27 Filter and total the last seven days
  6. 3:14 Rewrite the Weekly Summary sheet
  7. 3:50 Return the summary to Power Automate
  8. 4:18 Run the script and check the output
  9. 5:30 Add the Recurrence trigger
  10. 6:06 Add the Run script action
  11. 6:48 Email the report and test it
  12. 7:39 Recap

Key points

  • An Office Script starts from function main(workbook: ExcelScript.Workbook), and any extra parameters or return type become input fields and dynamic content in the Power Automate Run script action.
  • Excel stores dates as serial numbers, so compare whole serial days in the script and pass the report date from the flow, because Power Automate runs scripts in UTC.
  • The Run script action is limited to 1,600 calls per user per day and 3 calls per 10 seconds, and synchronous flow operations time out after 120 seconds.
  • Run script only lists scripts stored in your OneDrive; scripts saved in a SharePoint library need the Run script from SharePoint library action instead.
  • If you change a script's parameters or return type, remove the Run script action and add it again so the flow picks up the new signature.

In the full guide

Office Scripts: Automate a Weekly Excel Report With Power Automate (20 min read, Microsoft 365)

More videos

All EpiFive videos