This is my c# library I from which dll is generated, Also have enabled the COM visiblity in Property -> App,Build
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace howto_dll_for_excel
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("howto_dll_for_excel.CSharpTools")]
public class CSharpTools
{
[ComVisible(true)]
public string AddBrackets(string value)
{
return "[" + value + "]";
}
}
}
I am trying to access this dll in MS excel using vba as active X
I added the reference of the dll to this vba code,then created a button and this is the macro definition
Sub Button1_Click()
Dim sheet As Worksheet
Dim tools As howto_dll_for_excel.CSharpTools
Dim value As String
Dim result As String
Set sheet = ActiveSheet
value = sheet.Cells(1, 1)
tools = CreateObject("howto_dll_for_excel.CSharpTools")
End Sub
My problem is,
Here the first access of the project howto_dll_for_excel automatically lists the CSharpTools class,
but in the last CreateObject Statement ,it is not listing,even if I type it manually prompts error
"Compile error: Method or data member not found" .