MarshalAs problem, unmanaged dll in VBA

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
186 views
0

Hi.

Your example project is usefull. (Link : https://analystcave.com/excel-use-c-sharp-in-excel-vba/)
I’m trying to develop a project. However, if my function returns a string type, Excel crashes. “MarshalAs” didn’t work, would you suggest a solution?

My code:

<ComVisible(True)>
Public Module EntryPoints
Public Function TestFunction() As <MarshalAs(UnmanagedType.BStr)> String
Return "worked!"
End Function
End Module

0

Maybe try other UnmanagerTypes:
https://docs.microsoft.com/en-us/dotnet/framework/interop/default-marshaling-for-strings

You are viewing 1 out of 1 answers, click here to view all answers.

Simply the best place to learn Excel VBA