Guides

Practical guides for people who build and maintain Excel automations. Each one solves one task end to end, with code written for the guide and tested on a real machine, and says what it does not cover.

  1. Run an Excel Macro from PowerShell with a Timeout

    Run a trusted macro on a copy of the workbook, turn VBA errors into text instead of dialogs, stop at a time limit and close only the Excel your run started.

    · PowerShell 7, VBA

  2. Regression Test an Excel VBA Macro with a Golden File

    Approve a report's values once, then compare every new run with them: rows matched by key, tolerances per column, empty is not zero, and a check that runs in CI.

    · PowerShell 7, CSV, GitHub Actions

  3. Excel VBA Version Control with Git: Export and Verify

    Export every VBA module to text, keep line endings stable, review real diffs and check the export against a SHA256 manifest without Excel.

    · PowerShell 7, git, GitHub Actions

  4. PowerShell JSON to CSV Without Losing Columns

    Export-Csv takes its columns from the first record and drops the rest silently. Keep every column, flatten nested fields, write numbers with a dot and check the file before success.

    · PowerShell 7, JSON, CSV

  5. PowerShell ConvertTo-Json Depth: Stop Losing Nested Data

    ConvertTo-Json turns anything deeper than two levels into text, silently in Windows PowerShell 5.1. How levels are counted, three more ways the JSON changes, and a function that reads the JSON back before it writes the file.

    · PowerShell 7 and 5.1, JSON

  6. Excel VBA RefreshAll: Wait for Power Query and Catch a Failed Refresh

    RefreshAll returns before background queries finish and stays silent when a source is missing. Refresh each query table in the foreground, check it, and save only then.

    · VBA, Power Query

  7. Close Only the Excel Your PowerShell Script Started

    Stop-Process -Name EXCEL also closes the Excel someone has open, and Quit() alone can leave EXCEL.EXE running. Find your own Excel by its window, quit it in finally, and end only that process.

    · PowerShell 7, Excel COM

  8. Task Scheduler Says Success but Your PowerShell Script Failed

    A cmdlet error, a failed program or a swallowed exception can all end with Last Run Result 0. What reaches Task Scheduler in PowerShell 5.1 and 7, a template that exits 1 on any error, and a daily check.

    · PowerShell 7 and 5.1, Task Scheduler

  9. Import VBA Modules and UserForms Without Breaking References

    Import renames a module that already exists, a form without its .frx fails, ThisWorkbook code becomes a class and a missing reference stops everything. Import into a copy, restore the references and check by exporting again.

    · PowerShell 7, Excel VBA

  10. Clockify API Pagination to Excel: Read Every Page and Check What Is Missing

    Read every page of a REST API by its Last-Page header, catch duplicates and running timers, and write hours per project to an Excel workbook.

    · PowerShell 7, REST API, Excel

  11. PowerShell API 429 Too Many Requests: No Partial Data

    A paging script that hits a 429 on page 3 can save the pages it has and exit with code 0. What PowerShell 7's built-in retry does and does not do, and a script that waits for Retry-After, caps the wait and writes the file only when every page arrived.

    · PowerShell 7 and 5.1, REST API

  12. PowerShell: Fail When an API Property Is Null, Empty or Missing

    A null total becomes 0 in the report, next to a real 0, and nothing complains. What PowerShell 7 and 5.1 do with null, an empty string, an empty list and a missing property, why strict mode catches only one, and a check that names the property and the record and exits with 1.

    · PowerShell 7 and 5.1, JSON

  13. Excel CSV Import Drops Leading Zeros: Keep IDs as Text

    Open a CSV in Excel and 00123 becomes 123, 1E5 becomes 100000 and 12-34 becomes a date; saving makes it permanent. Which import methods keep text, the OpenText call that silently does not, and a PowerShell check that fails before the file reaches Excel.

    · PowerShell 7 and 5.1, Excel

  14. Power Query Merge Lost Rows: Find Them Before You Deliver

    An inner join drops the rows without a match, and a left join keeps them blank when a key differs by case or a space. Reproduced in Excel, with a merge that cleans the keys and a PowerShell check that counts rows and unmatched keys and fails with an exit code.

    · PowerShell 7 and 5.1, Excel, Power Query

Written by SteadyLatch, which makes the Automation Reliability Kit for Excel and VBA automations. The guides stand on their own; each ends with one short note about the kit.