I have standalone C # applications that do something specific (listens to the TCP port and pronounces all the lines that come to it through the speech synthesizer). How can I make a C # class visible to a VBA program, just like other "Links"? I would appreciate a short and clean example. I'm struggling to find one of them.
If there are some errors related to C # ↔ vba interaction, I would also like to know about it.
Here is the C # code. I am creating a class library with the setting "Registration for COM interoperability". When I add the resulting .tlb file to the VBA reference list, I expect to see the SayCom library, which has a SayCom class with two methods, a square and getCount. I do not see this. What am I missing?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
[assembly: CLSCompliant(true)]
namespace SayCom
{
[CLSCompliant(true)]
[ComVisible(true)]
public class SayCom
{
int count;
public SayCom()
{
count = 0;
}
[ComVisible(true)]
public int square(int x)
{
++count;
return x * x;
}
[ComVisible(true)]
public int getCount()
{
return count;
}
}
}