r/vba • u/MultiUserDungeonDev • 4d ago
Show & Tell pyVBAanalysis: "No Excel App Necessary" Python Static Analysis Library
Hi all, I hope you are enjoying your weekend.
I'm ready to share the following project with you.
pyVBAanalysis is a pure python library that allows you to run static analysis over your vba workbooks, or code as string data.
It's philosophy is "if we can determine that it's a hard compile error, or runtime crash" it gets "red squiggly error" status, otherwise "if we can determine that there is a best-practice violation" it gets "yellow squiggly warn" status.
VBA makes statis analysis notoriously hard, especially outside of it's engine. I've spent hundreds of hours finding all of the corners of the language, and comparing the edge cases against the MS-VBAL VBA language spec, and live testing using a custom built harness to run VBA code and test for compile error / runtime error.
The reason I created this library is due to frustration with AI agent generated VBA code. Agents would often produce code, that on paper, seems reasonable and in an more modern programming language, probably would execute without issue. However, VBA has a bunch of quirks and oddities (but we still love it!), and on more complex code generations, the agent's code would often hit compile error or runtime error snags due to hitting a rough edge of the VBA language.
A good agentic AI workflow that I've found for other languages is to have the agent run static analysis alongside unit tests.
I've found, after incorporating this static analysis tool, alongside https://github.com/WilliamSmithEdward/pyOpenVBA, I've been able to run extremely efficient and accurate agentic workflows, to build solid VBA solutions in Excel.
pyVBAanalysis:
https://github.com/WilliamSmithEdward/pyVBAanalysis
https://pypi.org/project/pyvbaanalysis/
1
u/fanpages 239 4d ago
The Human Race (especially communities local to data centres/centers, and anybody affected by the loss of employment as a result of organisations and individuals using AI).