1

I'm trying to delegate a huge processing VBA code to an outside application. My outside application can be a DLL file or an API. To do that I need to pass parameters from VBA to a DLL file Or the API. These parameters can be string, integer or an Array. I already found an example on how to pass Integers from VBA to DLL file

this is my C# code that have as an input three integers which will be sent by VBA. In this example I just generate the DLL file and I call it in VBA, but I need to do the same with arrays.

[Guid("A33BF1F2-483F-48F9-8A2D-4DA68C53C13B")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class MyFunctions
{
    public MyFunctions()
    {

    }

    public double MultiplyNTimes(double number1, double number2, double timesToMultiply)
    {
        double result = number1;
        for (double i = 0; i < timesToMultiply; i++)
        {
            result = result * number2;
        }
        return result;
    } 
}

How can I pass arrays from VBA TO DLL file or API ?

Hossein Golshani
  • 1,847
  • 5
  • 16
  • 27
Soufien Hajji
  • 477
  • 1
  • 8
  • 24
  • 1
    Where is your vba code? – QHarr Sep 18 '18 at 11:25
  • How do you invoke this code from your VBA? How do you pass values to it? What happens when you try passing a more complex type? – David Sep 18 '18 at 11:27
  • 1
    This is what i'm asking @David I need to do the same thing with more complexe variable types like arrays or matrixs and not only integers. – Soufien Hajji Sep 18 '18 at 11:41
  • @QHarr it's all in the response of this question : https://stackoverflow.com/questions/37074533/canonical-how-to-call-net-methods-from-excel-vba – Soufien Hajji Sep 18 '18 at 11:41
  • [Pass an array from vba to c# using com-interop](https://stackoverflow.com/questions/2027758/pass-an-array-from-vba-to-c-sharp-using-com-interop) ? – Alex K. Sep 18 '18 at 12:23

0 Answers0