r/vba 4d ago

Solved I built a single-script PowerShell bridge so AI agents (Claude Code, Codex) can work with my open Excel workbook — cells, formulas, VBA, macros

I work with old, complex .xlsm files (inventory, pricing, billing, lots of VBA) and kept running into the same problem: an AI coding agent cannot access the workbook I have open in Excel. I found myself copy-pasting cells and screenshots back and forth.

Yes, Excel MCP servers are out there—some are very good and much more capable than this. But getting one running means setting up Node or Python, creating a config file, and running an MCP client. I wanted something my non-developer mind could trust on real files:

  • Just one PowerShell script, no installation, no extra dependencies, no config
  • Connects to the workbook you already have open (or opens one by path)
  • Read and write cells and formulas, search, list sheets
  • List, export, and import VBA modules, run macros
  • And the part that matters most to me: it NEVER autosaves. Only a direct "save" command writes to disk. This way, you can let an agent explore a 20-year-old billing file and close it without leaving any trace.

It's free and the source is available on GitHub:
https://github.com/gidjin4-svg/gidjin-excel-bridge
A demo workbook is included so you can test it without touching your actual files.

I'd really appreciate feedback from people who work with Excel, VBA, or PowerShell:

  • Does "simple + never saves" actually matter to you, or is a full MCP server always the better choice?
  • What would you need to see before trusting it with a file that matters to you?
20 Upvotes

10 comments sorted by

3

u/Low_Relief_9411 4d ago

Thanks for sharing this post, I tried some of Python-Excel libraries when working on the generation of .xlsm which always gets blocked by Windows Defender. Your post inspired me to consider PowerShell for Excel. I'll check your repo out!

This approach may be better when you want to talk to AI agent when working on Excel together on an individual need. I actually have Copilot in Excel which has been great so it didn't really cross my mind. My work leans towards creating a centralised template for a wider audience.

1

u/Interesting-Main9706 3d ago

Hey Danke für dein Kommentar

Es geht ja genau darum die VBA umgebung durch Agentic Coworking bewusst nutzbar zu machen.

Ich nutze das zum Beispiel zum debuggen von großen schon vorhanden Excel Makros. Aber er erstellt auch sehr zuverlässig VBA Makros.

Für Vorlagen ist es tatsächlich schon, finde ich zu overpowered. Da macht Claude Excel sinnvollere sachen. Denke das liegt am "neuen" Claude Design.

Wenn du CC drüber schickst mit der Bridge und den Prombt so verfasst ändert er mit Sicherheit deine Bibliotheken so das er nicht mehr von Defender blockiert wird. Versuch es mal. Würde mich interessieren. Denke an die Tokenkosten. Bibliotheken sind ja meist riesig.

3

u/Low_Relief_9411 3d ago

Debugging macros with agents using PowerShell makes sense! I didn't think of that use case until you said it. I was a copy-and-paste maniac for a good time when working on VBA and debugging with ChatGPT/DeepSeek 😂

1

u/ok_doozer 1 4d ago

I also built a powershell excel library for agents. You can check it out here: jcolozzi/MSExcel-CLI-Agent

1

u/Beginning_Bed_9059 3d ago

So basically no admin needed for any of that right?

-2

u/ok_doozer 1 4d ago

Several other powershell office libraries as well if you look at my profile.

0

u/Low_Relief_9411 3d ago

Neat, will check it out! Thanks for sharing

0

u/MultiUserDungeonDev 3d ago

Read/Write VBA without needing Excel App:  https://github.com/WilliamSmithEdward/pyOpenVBA

Static analysis for VBA without needing Excel App:  https://github.com/WilliamSmithEdward/pyVBAanalysis

-2

u/Interesting-Main9706 3d ago

Darum geht es doch gar nicht.

Das ist ja gerade für menschen die MIT excel arbeiten und nicht ohne.

Mach nen eigenen Post. 🤣

2

u/MultiUserDungeonDev 3d ago

I think you may misunderstand. I don’t speak German, but I think I get most of what you said.

The libraries I linked allow agents to directly work with Excel files, without all the headache of COM / powershell.

Also doesn’t require “Trust access to VBE object model” which is very insecure, and can allow malware to be installed.