Monkey Patching in VBA

5 days ago (ecp-solutions.github.io)

VBA is permanently disabled in most large corporate and government environments these days as a security precaution.

Interesting to see this HN user on a campaign to promote a boutique new language running on top of VBA which seems like a dead end.

20251227 https://news.ycombinator.com/item?id=46403704 Hacking VBA to support native scripting runtime with no COM dependencies

  • >VBA is permanently disabled in most large corporate and government environments these days as a security precaution.

    This is exactly the argument used for deprecating a so powerful language, but It's all a Microsoft marketing strategy. Organizations creating and running only their workbooks are equally enforced to shutting down VBA, Why? Because VBA doesn't pay Microsoft rent.

  • I'll counter argue that "large corporates" are exactly the environment with a massive legacy of VBA based Excel spreadsheets stapled together handling half the businesses most critical functions.

If it's not immediately clear toyou what this thing (ASF) (like it wasn't to me) this quote from the Github README is useful:

> JavaScript-like scripting language implemented entirely in VBA. Zero COM dependencies. Native Office object model integration with runtime monkey patching capabilities.

That's bananas!

The specific feature being referred-to by the current title ("Monkey Patching in VBA") is functionality to allow you to override or add additional methods to the stock Office COM objects in this ASF scripting language. That's wild.

The extensibility of the Office object model using VBA is powerful and horrifying.

I thought that the VBscript engine, accessible from cscript.exe, also has a builtin JavaScript frontend. The idea being that both of these are a scripting language that can interact with COM objects. No idea if the various embeddings of VBScript such as excel or ASP can use js out of the box though.

  • Active Scripting is the technology you are thinking of, JScript and VBScript are just the frontends for it that are shipped with Windows. It's honestly a pretty cool idea on the surface (coming from someone that's never actually used it anyway), you could develop/obtain an implementation for your favourite language, access the same functionality exposed by ASP/Office/IE, and as script hosts they would be none the wiser as to what language was being used (of course, it gets less useful the more users you have to ask to install your plugin).

    The closest modern thing that's like this I can think of is Godot and its GDExtension.

  • As the sibling comment notes, VBScript isn't JScript, though both are executed by the Windows Script Host (wscript/cscript). JScript had already been deprecated in 2009 with IE 8.

    VBScript is deprecated since 2023 and in the process of being removed: https://techcommunity.microsoft.com/blog/windows-itpro-blog/...

    You also cannot run VBScript (nor JScript) from VB or VBA, other than invoking it as a separate process. VBA is not an "embedding of VBScript". VB/VBA are compiled to an intermediate representation called P-code, they aren't scripts in the sense of being executed from a textual representation like VBScript/JScript.

  • I believe you're thinking of JScript, they're not quite the same thing.

VBA is an interesting language. The builtins are huge - C++ may never have a loan amortization primitive, but VBA sure did/does