Pass String Between VB.NET and VBA
Posted on 2010-11-29
I am trying to create a VB.NET DLL that does functions for Excel VBA. I am trying to pass strings back and forth between the VB.NET functions and VBA. I am having a bunch of problems. I am very experienced with VBA but new to VB.
I am exposing through COM. First, I created a structure in the VB DLL that was to be used by both the VB functions and the VBA. When I add a string variable type into the structure, VBA doesn't recognize the structure at all. When I take out the string, the structure works fine. I then tried to create a VB function that returns a string, and VBA didn't like that. The function in VB is:
Public Function GetString() As String
Return "That's nice"
When I try to call it from VBA I get "Object doesn't support this property or method".
So my questions are: how do I pass a string between VB and VBA? How should I define the string in both languages so that they can communicate?