Excel-Dna working great... then I got stuck. Help! How to pass exactly 2 or 3 parameters?

Jan 15, 2014 at 10:02 PM
Edited Jan 15, 2014 at 10:03 PM
Hello,

I am having trouble getting more than one parameter to pass back to my Excel-Dna functions.

Basically I have one function that's:
public object[,] DoSomething(object[,] inputValues) {
   (code doing stuff)
}
That I can get to work fine when I pass a 2D variant from VBA using MyAddIn.DoSomething(myArray). What I've gotten stuck on is:
public object[,] DoSomethingElse(object[,] inputValues, object[,] otherValues) {
   (code doing stuff)
}
When I try MyAddIn.DoSomethingElse(myArray1, myArray2) in Excel VBA, I get an error message of:
Run-time error '5':
Invalid procedure call or argument
Perhaps I just don't know the terminology to search for and find my answer, but surely its possible to pass more than one parameter for a function to use. Can anyone point me in the right direction?

Edit: spelling
Coordinator
Jan 17, 2014 at 8:26 AM
Edited Jan 17, 2014 at 8:27 AM
Hi,

Can you explain how you are getting the MyAddIn object in your VBA?
If you've set the .NET project to 'Register for COM interop' you might find that the VBA side has cached the COM interface information, and you can't add or change methods so easily (COM interfaces are not allowed to change).
It's better if you can do the registration via the Excel-DNA .xll itself, wither with RegSvr32 or a call to ComServer.DllRegiserServer() in your add-in's AutoOpen.

Anyway, the problem is not likely to have anything to do with the number of parameters, but either the values you're passing in, or the COM stuff above.

-Govert