Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Passing Object from VBA to C#

Options
  • 12-05-2010 4:05pm
    #1
    Registered Users Posts: 1,830 ✭✭✭


    Hi All,

    I've got a VBA / C# 2005 DLL project.

    I want to pass on object from the VBA to the C# DLL. Do I need to do this through an interface?


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Is VBA still based on VB6? If so you can use an interop. If its .NET based you should be okay with native .Net types I think. My memory is not what it used to be. Shouldn't be a big job to convert from VB.NET to C# anyway.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Yes you can

    You will need to use REGASM to register the assembly that is COM visible so that your VBA application can use it

    Details on REGASM http://msdn.microsoft.com/en-us/library/tzat5yw6%28VS.80%29.aspx

    Examples http://weblogs.asp.net/psteele/archive/2004/06/16/157767.aspx

    Normal convention would be regasm MyAssembly.dll /t:MyAssembly.tlb


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    To pass the VBA object to C# dll that understands it

    myVBAobject = FunctionThatReturnsIt()

    Set NetObject = CreateObject("NETProject.Bar")

    NetObject.AcceptClass(myVBAObect)

    Provided that your .NET class knows what to expect it should be ok...


Advertisement