Passing an array of Arguments to CallByName VBA
<p>I'm using callByName I VBA to dynamically call different methods of a class. Depending on the method, I will have a different number of arguments which will be held in an array. Unfortunately CallByName accepts a param array, therefore it's not straightforward to pass a variable number. Is there a way around this, I found a solution using the Type Information Library but this does not seem to work on VBA even though I have added it as a reference. Below is an illustration of what I want</p>

<pre><code> Public Sub Initialize_Object(ByRef TaskObject, Task_Collection)

 Dim Task_begin As Variant, Method_Parameters As Variant

 Task_begin = Task_Collection("Method")

 CallByName TaskObject, Task_begin, VbMethod, Method_Parameters
</code></pre>