0

I am new to C# and am trying to create DLLs with functions that I can use in VBA. I have created a test DLL with simple functions that work fine when referenced in another C# assembly. I am also able to reference the DLL in VBA, and the class created by it (named FunctionsVS) appears in the object browser.

In VBA, I have the following code snippet:

Sub Test1()
    Dim z As Integer
    Dim func As New FunctionsVS
    z = func.Add(4, 5)           
End Sub

When I run this sub, I get I get an error message stating

"Class not registered".

I have tried to register the DLL with regsvr32 but I get an error stating:

The module "c:\windows\system32\functionslibframework.dll" was loaded but the entry point DllRegisterServer was not found.

Any advice would be greatly appreciated.

The C# code I used to create the DLL is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunctionLibVS
{
    public class FunctionsVS
    {
        public int Add(int x, int y)
        {
            return x + y;
        }

        public int Multiply(int x, int y)
        {
            return x * y;
        }
    }
}
Dennis
  • 107
  • 3
  • 1
    Does this answer your question? [Using a C# dll inside EXCEL VBA](https://stackoverflow.com/questions/6340041/using-a-c-sharp-dll-inside-excel-vba) – Hamid Reza Mohammadi May 08 '20 at 00:34
  • Does this answer your question? [Using a C# dll inside EXCEL VBA](https://stackoverflow.com/questions/6340041/using-a-c-sharp-dll-inside-excel-vba) – Flydog57 May 08 '20 at 01:28

0 Answers0