-1

I wrote a C# .dll in Visual Studio which I want to call from excel VBA. (I used this tutorial)

On my Development PC where I set the settings in the Project properties for "Make COM-Visible", "Register for COM interop" and "sign the assembly" it all works fine. The dll is getting registered automatically by Visual Studio and I can select and set it in Excel in VBA Window > Tools > References

The use case now is that I can use that dll file on another PC which does not have Visual Studio installed.

As told in the tutorial and all around the internet the way to go is by using the command line tool RegAsm.exe, what I did (if its useful: I used the one in the following folder: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe)

The command to register the dll is:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe D:\Debug\DotNetLibrary.dll /tlb /codebase.

This runs without an error and the command line tells me that the types have been registered correctly and the tlb has been exported and registered.

It seems like everything worked well and there is also an entry in the registry (Computer\HKEY_CLASSES_ROOT\TypeLib) which references my dll but the library doesn't show up in the Reference window in VBA like it did on the other PC.

If I select the tlb, which has been generated by the RegAsm manually, by clicking browse in the Reference Window, it gets added to the list. But if I then start the code I get the Error that the ActiveX component can't create an object.

I'm inspecting this issue since several days now, so it would be very nice if some one could assist me with it.

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
Linus
  • 11
  • 2

1 Answers1

0

As @HansPassant mentioned in an comment under my question the simple solution was to use the 32-bit version of regasm (located in C:\Windows\Microsoft.NET\Framework\v4.0.30319) This needs to be done because Microsoft Office products are still 32-bit.

Linus
  • 11
  • 2