My C# library (.net 4.5.2) code looks like this:
namespace HelloWorld
{
public class Hello
{
public string HelloUser(string name)
{
return "Hello, " + name;
}
}
}
I have made the assembly COM visible in AssemblyInfo.cs file using the following code:
[assembly: ComVisible(true)]
I added the reference to the dll in VBA code via Tools ->References and when trying to use the same in excel vba, I am getting Run-time error: 429 (ActiveX component can't create object). What's wrong with my code/call:
Excel VBA (2013)
Option Explicit
Sub tester()
Dim message As String
Dim User As String
User = "Ronnie"
Dim obj As New HelloWorld.Hello
message = obj.HelloUser(User)
End Sub
UPDATE
After adding reference via Toos ->References and checking the status using F2
UPDATE #3 Updated the VBA code and still no success. This time the error is:
Run-time error: 429 (ActiveX component can't create object)