Office Scripts + Power Automate: Schedule Excel Reports Automatically
A hands-on guide to scheduling Excel reports using Office Scripts and Power Automate. From your first script to weekly automation.
You've probably heard that VBA macros are the way to automate Excel. For decades, that was true. But Microsoft has been quietly building something better: Office Scripts, accessible through the Automate tab in Excel for the web, designed from the ground up to work with Power Automate for scheduled, cloud-native automation.
This guide shows you how to combine these two tools to schedule Excel reports that run automatically—no VBA required, no desktop Excel needed, no remembering to click "Run" every Monday morning.
Why Office Scripts + Power Automate?
Office Scripts is Microsoft's modern answer to VBA. Instead of macros that live on your desktop and break when you change computers, Office Scripts are TypeScript-based, stored in OneDrive, and run in Excel for the web. They're shareable, version-controlled, and—critically—they integrate natively with Power Automate.
| Aspect | VBA Macros | Office Scripts |
|---|---|---|
| Location | Desktop Excel only | Excel for the web (M365) |
| Language | VBA | TypeScript |
| Sharing | Copy/paste code | Stored in OneDrive, share via link |
| Scheduling | Requires Task Scheduler workarounds | Native Power Automate integration |
| Cross-platform | Windows only | Any browser |
The combination works like this: Office Scripts handles the Excel manipulation—formatting, calculations, data updates. Power Automate handles the orchestration—scheduling, triggering, sending emails, connecting to other apps. Together, they solve the "I have a script but I have to remember to run it" problem.
The Hands-On Example: Weekly Cash Position Report
Maria is the finance manager at a 25-person construction company. Every Monday morning, she prepares a cash position report:
- Opens
Cash_Position_Master.xlsxon OneDrive - Updates the "This Week" column with current bank balances
- Highlights any negative balances in red
- Calculates projected cash for the next 4 weeks
- Saves a timestamped copy
- Emails the summary to the CFO and two project managers
Time: 45 minutes every Monday. The steps are identical each week. This is exactly what Office Scripts + Power Automate was built for.
Step 1 — Write Your First Office Script
Accessing the Automate Tab
Open your workbook in Excel for the web (not desktop Excel). Click the Automate tab in the ribbon. You'll see two options:
- Record Actions — Records your clicks and keystrokes as a script. Good for simple tasks.
- New Script — Opens the code editor directly. Better for anything beyond basic formatting.
Note: Office Scripts requires a Microsoft 365 business license with the feature enabled. If you don't see the Automate tab, check with your IT admin.
A Simple Script Walkthrough
Here's a stripped-down example of what Maria's script might look like:
function main(workbook: ExcelScript.Workbook) {
// Get the Summary worksheet
let summary = workbook.getWorksheet("Summary");
// Update the report date
let dateCell = summary.getRange("B1");
dateCell.setValue(new Date().toLocaleDateString());
// Get the balance range and highlight negatives
let balanceRange = summary.getRange("C5:C10");
let values = balanceRange.getValues();
for (let i = 0; i < values.length; i++) {
let cell = balanceRange.getCell(i, 0);
if (values[i][0] < 0) {
cell.getFormat().getFill().setColor("#FFCCCC"); // Light red
} else {
cell.getFormat().getFill().setColor("#FFFFFF"); // White
}
}
}
The script accesses worksheets, reads and writes cell values, and applies formatting. Office Scripts can do most things you'd do manually in Excel—just programmatically.
Test Before You Automate
Run the script manually first. Click the Run button in the code editor and verify the output. Check that formatting applies correctly, values update as expected, and nothing breaks. Never automate what you haven't validated by hand.
Step 2 — Connect Power Automate
With a working script, the next step is scheduling it to run automatically.
Creating a Scheduled Cloud Flow
- Go to flow.microsoft.com
- Click Create → Scheduled cloud flow
- Name your flow (e.g., "Weekly Cash Position Report")
- Set the recurrence: Weekly, Monday, 7:00 AM
- Choose your timezone carefully—this matters
Adding the Run Script Action
- Click New step
- Search for "Excel Online (Business)"
- Select Run script
- Configure:
- Location: OneDrive for Business (or SharePoint)
- Document Library: OneDrive
- File: Browse to your workbook
- Script: Select your saved Office Script
Adding Email Distribution
- Click New step
- Search for "Office 365 Outlook"
- Select Send an email (V2)
- Configure recipients, subject, and body
- To attach the file, use the Attachments field with the file content from OneDrive
The complete flow looks like this:
┌─────────────────────────┐
│ Recurrence │
│ Every Monday, 7:00 AM │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Run Office Script │
│ Cash_Position.xlsx │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Send Email │
│ To: CFO, Project Mgrs │
│ Attach: Report link │
└─────────────────────────┘
Practical Considerations
What Office Scripts Can and Cannot Do
| Task | Office Scripts? | Alternative |
|---|---|---|
| Format cells based on values | Yes | — |
| Read/write cell values | Yes | — |
| Create tables and charts | Yes | — |
| Pull data from another workbook | No | Use Power Query first |
| Send email | No | Power Automate handles this |
| Generate PDF | No | Power Automate "Create PDF" action |
| Run on a schedule | No | Power Automate handles this |
| Access local files | No | Files must be in OneDrive/SharePoint |
Error Handling
Automated processes need automated failure alerts. In Power Automate:
- After the "Run script" action, add a Condition to check if it succeeded
- In the "If no" branch, add a Send email action to notify yourself
- Configure Run after settings so failure notifications always send
A flow that fails silently is worse than no automation at all.
Documentation
Office Scripts are stored in your OneDrive under Documents/Office Scripts/. Keep your scripts organized:
- Use clear, descriptive names (
Weekly_Cash_Position_Update.osts) - Add comments in the code explaining what each section does
- Maintain a simple changelog at the top of the script
When you leave or someone else needs to maintain this, they'll thank you.
When This Approach Hits Its Limits
Office Scripts + Power Automate handles single-workbook, predictable workflows well. But you'll outgrow it when:
- Multiple workbooks need to interact — Scripts run on one workbook at a time
- Data comes from non-Microsoft sources — Salesforce, databases, custom APIs
- Complex conditional logic — "If cash is negative AND it's month-end, escalate to the CEO"
- Human approval is needed before distribution — Scripts can't pause for review
- Files live in multiple cloud providers — OneDrive, Google Drive, Dropbox
| Scenario | Level 3-4 (Scripts + Flows) | Level 5 (AI Agents) |
|---|---|---|
| Single workbook, fixed schedule | Ideal | Overkill |
| Multiple sources, same format each time | Manageable | Good fit |
| Cross-system with exceptions | Stretched | Ideal |
| Requires human review before sending | Manual workaround | Built-in approval workflows |
When your automation needs exceed what scripts and flows can provide, agentic orchestration platforms handle cross-system complexity with natural language instructions and built-in approval workflows—the next rung on the automation ladder.
Getting Started Checklist
- Verify your Microsoft 365 license includes Office Scripts
- Identify one recurring Excel task (weekly or monthly, same steps each time)
- Document every manual step you currently perform
- Write and test the Office Script in Excel for the web
- Create a scheduled Power Automate flow
- Add success and failure notification steps
- Run a full test cycle before the next real deadline
- Document the flow for your team
Moving Forward
Office Scripts + Power Automate is the practical bridge between manual Excel work and fully automated workflows. It's not the final destination—but it's a reliable, maintainable step that most SMEs can implement in a day.
Start with one report. One script. One flow. Build confidence through working automation. And when you find yourself hitting limits—multiple data sources, judgment calls, approval workflows—you'll know you're ready for the next level.
The 45 minutes Maria spent every Monday? Now she spends 5 minutes reviewing an automatically-generated report. The process runs whether she's in the office or not. That's the value of automation that actually works.
reflexion