Executing streamed in VBA code

Dec 3, 2013 at 1:45 PM
Edited Dec 3, 2013 at 1:51 PM
Hi Govert,
Could you suggest to me how I might enable my add-in to execute Vba code that I have stored on a server and will stream in through a webapi or webservice call? We anticipate storing many vba code scripts so would like to load and execute these modules dynamically. Much appreciated.

Regards,
Mark
Coordinator
Dec 26, 2013 at 7:36 PM
Hi Mark,

This should be possible if you can use VB.NET code, and use the .NET infrastructure at runtime.

You need to follow similar steps to what Excel-DNA does to compile and load the code at runtime, using the CodeDom compiler interfaces to compile the code to an assembly (with all the right references) and then using reflection to get the methods (Functions and Subs) that you want to register in Excel.
One could even look at whether some small changes to Excel-DNA could help support this (given that loading dynamically from some loose code files is already supported).

-Govert