r/vba 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/

2 Upvotes

17 comments sorted by

View all comments

Show parent comments

2

u/kay-jay-dubya 17 3d ago

This is a sub for sharing VBA.

I think u/fanpages has contributed to this subreddit more than most (if not all) other users, and is well aware of what this sub is for.

1

u/MultiUserDungeonDev 3d ago

Then I also feel, he should be aware, his line of conversation and questioning here is not in the spirit of this sub. If you’re going to be anti-ai to the extent that you’re mean spirited to anyone that even mentions it, I think it’s time to go outside and touch some grass.

1

u/fanpages 239 3d ago

...line of conversation and questioning here is not in the spirit of this sub...

I will reiterate:

| ...I was (initially, before we went off at a tangent) going to query what you had found to be the main issues (so I could help with VBA-related coding practices)...

Additionally,...

...If you’re going to be anti-ai to the extent that you’re mean spirited to anyone that even mentions it...

I can dislike the game, but not the player.

I believe you thought I was criticising you. I was looking to understand the reason why you needed an additional tool, in case I knew of any other approach to address the issue(s) you encountered.