samedi 23 janvier 2016

How to Pass empty C# parameter to VBA method expecting a ParamArray argument

I have a COM application object that has a VBA method signature like:

Function DoSomething(ActivityName As String, ParamArray ActivityParams() As Variant)

I'm trying to call the function from my C# code, but I'm unsure how to pass values to the 2nd argument ActivityParams(). I should be able to pass no ActivityParams, or one, or many, so I'm guessing an array at the C# end will be required.

For now, I don't need to pass any ActivityParams values at all, for the second argument, but I probably will need to soon enough.

Is this sufficient to call the DoSomething method, if I don't have any values to pass to ActivityParams?

public override void DoSomething(MyActivity myActivity)
    {
        Application.DoSomething(myActivity.ToString(), null);
    }

And, how would I vary it to be flexible enough to pass 0, 1 or more values?





Aucun commentaire:

Enregistrer un commentaire