I am building an excel add in that allows users to run a function that creates further functions at runtime.
So far, I have been able to register new excel functions at runtime using:
ExcelAsyncUtil.QueueAsMacro(() => {
ExcelIntegration.RegisterDelegates(delegates, methodAttributes, argumentAttributesCollection);
ExcelDna.IntelliSense.IntelliSenseServer.Refresh();
});
The add in also supports VBA with the use of a COM server. E.g:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("Test123")]
public partial class VBAFunctions : IVBAFunction
{
public object MyFunc() => "Hello World!";
}
Then from VBA:
Dim lib As Object: Set lib = CreateObject("
Test123")
Dim arr As Variant
arr = lib.MyFunc()
I am wondering if it is possible to add functions at runtime to be accessed via VBA in a similar fashion to adding excel functions as above? Thanks!