Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You haven't described in detail how your created your .NET assembly. However, there are a certain number of steps required to expose the assembly to COM:</p> <ul> <li><p>Add the following attributes to your code:</p> <pre><code>using System; using System.Runtime.InteropServices; namespace SimpleLibrary { [ComVisible(true)] [Guid("71F645D0-AA78-4447-BA26-3A2443FDA691")] public interface ISixGenerator { int Six(); } [ComVisible(true)] [ProgId("SimpleLibrary.SixGenerator")] [Guid("8D59E0F6-4AE3-4A6C-A4D9-DFE06EC5A514")] [ClassInterface(ClassInterfaceType.AutoDispatch)] public class SixGenerator : ISixGenerator { [DispId(1)] public int Six() { return 6; } } } </code></pre></li> <li><p>Your assembly must be signed (<em>Project -> Properties... -> Signing</em>, create a strong key file and check the box to sign the assembly</p></li> <li><p>The following command is necessary to register the assembly (all in one line):</p> <pre><code>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe SimpleLibrary.dll /tlb SimpleLibrary.tlb /codebase </code></pre> <p>This creates a .tlb type library file which you will have to reference from your VBA project (<em>Tools -> References -> Browse...</em> in your VBA editor)</p></li> <li><p>Adjust the VBA code:</p> <pre><code>Public Function GetSix() Dim lib As SimpleLibrary.SixGenerator Set lib = New SimpleLibrary.SixGenerator GetSix = lib.Six End Function </code></pre></li> </ul> <p>You will find the steps described in more detail in this article on Microsoft's support database:</p> <blockquote> <p><strong><a href="http://support.microsoft.com/kb/817248" rel="nofollow noreferrer">How to call a Visual Basic .NET or Visual Basic 2005 assembly from Visual Basic 6.0</a></strong></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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