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 a
You can't do this dynamically because different methods will require a different amount of arguments and you can't pass arguments where they aren't expected.
If you know the amount of arguments required, then you could call each item of the array and pass that:
CallByName TaskObject, Task_begin, VbMethod, Method_Parameters(0), Method_Parameters(1), Method_Parameters(2)
but you would probably have to set up a Select Case block or similar to handle all the different methods:
Select Case Method_Name
Case "Method_1": CallByName TaskObject, Task_begin, VbMethod, Method_Parameters(0), Method_Parameters(1)
Case "Method_2": CallByName TaskObject, Task_begin, VbMethod, Method_Parameters(0)
Case "Method_3": CallByName TaskObject, Task_begin, VbMethod, Method_Parameters(0), Method_Parameters(1), Method_Parameters(2)
End Select
Which can get messy quite easily.