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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Passing Object from VBA to C#

  • 12-05-2010 3:05pm
    #1
    Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭


    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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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