Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>And to expand on registering the DLL on different computers.</p> <p>Once you compile and build the above code on your development machine, if you have</p> <blockquote> <p>The project properties Build tab, select Register for COM interop.</p> </blockquote> <p>your Visual Studio output folder (usually bin\Debug) where the compiled *.dll is found will also have a *.tlb file.</p> <p>This *.tlb file is a 'Type Library'. And is needed by the client machine to understand the different 'Types' in your *.dll and to basically tell the client machine how to use it.</p> <p>By setting the above 'Register for COM interop' -- aswell as a *.tlb file being produced, the assembly(dll) is registered on your machine, and is therefore accessible.</p> <p>In VBA you can now add this file as a reference by</p> <blockquote> <p>VBA Editor -> Tools -> References -> Browse -> Select</p> </blockquote> <p>this will allow you to then declare the classes found in your library.</p> <pre><code>Dim TestClass As Test Set TestClass = New Test MsgBox TestClass.HelloWorld </code></pre> <p>HOWEVER - if you want to then use your dll on a different client machine, you will have to use regasm.exe - to register the assembly(dll) on that machine.</p> <p>This can be done by the command line,</p> <blockquote> <p>regasm.exe </p> </blockquote> <p>in this case</p> <blockquote> <p>regasm.exe TestDll.dll</p> </blockquote> <p>once you have registered the assembly on the new client machine, you will be able to access it by again adding a reference to its *.tlb</p> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload