Logan's Analytics Bootcamp
Dashboard β€Ί Phase 3: Power Automate
M3.3

Office Scripts + Power Automate (Excel Automation in the Cloud)

⏱ 5 hoursπŸ“… Week 17❓ 3 quiz questions
Phase 3 goal

Replace manual chasing, copying, and emailing with flows that move data between Excel, SharePoint, Teams/Outlook, and Power BI, and that alert people when program metrics cross thresholds.

Licensing note: Standard connectors (SharePoint, Excel Online (Business), Outlook, Teams, Approvals, Power BI) come with most Microsoft 365 licenses. Premium connectors (e.g., HTTP, SQL, Dataverse in some cases) need extra licensing. Your environment may also have DLP policies that block some connector combinations. Check your tenant before you design.

🎯 Learning objectives

Tick each one when you can actually do it.

πŸ’‘ Key concepts

  • Office Scripts: Excel on the web automation (Automate tab). The Action Recorder writes the code for you, and you edit it in the Code Editor. Saved to OneDrive/SharePoint, so it works with flows (VBA doesn't run in cloud flows).
  • Script with parameters and a return value:
    function main(workbook: ExcelScript.Workbook, threshold: number): string[] {
      const table = workbook.getTable("EVMSnapshot");
      const values = table.getRangeBetweenHeaderAndTotal().getValues();
      const headers = table.getHeaderRowRange().getValues()[0] as string[];
      const iProg = headers.indexOf("ProgramID");
      const iCPI = headers.indexOf("CPI");
      const flagged: string[] = [];
      values.forEach(r => { if ((r[iCPI] as number) < threshold) flagged.push(r[iProg] as string); });
      return flagged;
    }
    
  • Run script action in Power Automate passes threshold and receives flagged as dynamic content.
  • Tool choice:
    Need Best tool
    Reshape and clean incoming data Power Query
    Format, rearrange, or stamp a workbook in the cloud on a schedule Office Scripts + Power Automate
    Desktop-only legacy macros VBA (not callable from cloud flows)
    Heavy transforms, Word/Excel document generation, complex logic Python (Phase 4)

πŸ›  Hands-on exercise: Format-and-Stamp Script

⬇ Practice data for this module
D1 programsProgram dimension (12 rows)CSVXLSX

Data: An Excel workbook in OneDrive with Table EVMSnapshot (ProgramID, ProgramName, CPI, SPI, CV, SV, EAC, VAC, PeriodEnd).

  1. Record a script that applies number formats, freezes the header row, applies RAG fill to CPI/SPI, and stamps "Generated: " in a header cell.
  2. Edit the code so thresholds are parameters.
  3. Build a flow: scheduled monthly β†’ Run script β†’ email the workbook link to yourself.

πŸ“¦ Mini-project: Flagged Programs Digest

Use the parameterized script above (returns an array of flagged programs) in a flow that builds an HTML table of flagged programs (Select + Create HTML table) and emails a digest to a distribution list only when at least one program is flagged (length(...) > 0).

🧠 Self-check quiz

Answer in your own words, then check. Grade yourself honestly; your score is saved.

Q3.3.1
Why can't a cloud flow run a VBA macro?
Write at least a few words to unlock.
Q3.3.2
How does a flow get data back from an Office Script?
Write at least a few words to unlock.
Q3.3.3
What's the easiest way to start writing an Office Script?
Write at least a few words to unlock.