Translate VBA macros to TypeScript
4 min
Each VBA module becomes a placeholder `.ts` file with the original code as a header comment + a per-feature translation guide.
VBA-to-TypeScript automatic translation isn't reliable enough yet — the languages share a lot but enough diverges (variant types, late binding, the Excel COM object model) that a fully automated port produces buggy code more often than not. Avery's spreadsheet-vba-generator takes a different approach: scaffold the placeholder, document the equivalents, let you finish the port.
For each VBA module / class / form module in the workbook, the generator emits `lib/vba/<module>.ts` containing:
• The original VBA source as a `/* ... */` header comment (no information loss — the source is right there next to the port). • TypeScript function signatures matching every VBA Sub / Function the module exports. • An empty body in each that throws `new Error("VBA port pending: see header comment")` so the generated app fails fast on call rather than silently misbehaving. • A per-feature translation guide at the top of each module pointing at the relevant TypeScript / Next.js APIs: VBA pattern → TypeScript equivalent "Range(\"A1\").Value = 5" → Prisma update, OR write through the sync push API "MsgBox \"hello\"" → toast notification (sonner / shadcn) "Dim db As DAO.Database" → Prisma client (already imported as `prisma`) "Application.OnTime" → cron in `Automations` tab "Workbook.Worksheets(...).Range" → direct sheet access via the xl.* runtime
For most workbooks the VBA modules are short helper macros (formatting, sending an email when a row changes, recalculating a derived column). 30-60 minutes of porting per module is typical. The generator's value is a) preserving the source for reference, b) telling you which TypeScript pattern replaces each VBA pattern, c) giving you typed function signatures so the rest of your app can already CALL the eventual port.
Live recipes need the desktop
This article is a static preview. The in-app Help sidecar inside Avery NXR can fire each step against your live project — install the desktop to use it interactively.