♪ write dll to access ♪



  • It's like c# writing dll for access, a good example. I've tried to--my dll connects, but when it's called in the access code, it's a mistake-- it's an entry point.



  • We're setting up a dll for example ClassLibrary1 in Visual Studio 2015.

    In the project's properties, Build needs a parameter. Platform and Register for COM interop: введите сюда описание изображения

    The platform should be displayed to indicate the tiles-registerer which COM records x86 or x64. I tested with MS Office x64, so I had to make a platform mandatory.

    It should also be noted that in this case, Visual Studio is trying to register COM object, which means that it should be launched on behalf of the administrator.

    Writing class at C#:

    using System.Runtime.InteropServices;
    

    namespace ClassLibrary1
    {
    [ComVisible(true)]
    public class Class1
    {
    public string GenerateMessage()
    {
    return "Hello, World!";
    }
    }
    }

    We'll test it at VBA:

    Private Sub ShowMessage()
    Dim o1 As Object
    Set o1 = CreateObject("ClassLibrary1.Class1")

    Dim msg As String
    msg = o1.GenerateMessage()
    
    MsgBox msg
    
    Set o1 = Nothing
    

    End Sub




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2