Passing VBA class module instance BYREF to .NET DLL, MS ACCESS refuses to close

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VaBa
    New Member
    • Apr 2008
    • 1

    Passing VBA class module instance BYREF to .NET DLL, MS ACCESS refuses to close

    Hi,

    Need some help.. I have a VBA class module in MS ACCESS. In the same MS ACCESS app, I am calling a .NET DLL (which i have exposed as COM-visible) and passing BYREF an instance of the VBA class module as an argument to one of the .NET DLL method. Step by step, here's what i am doing:

    1. Create vba class module in MS ACCESS
    Option Compare Database
    Option Explicit
    ...
    Public Function DoSomething(ByV al S as String, ByRef RetVal as Double) As Long
    RetVal = 100
    DoSomething = 0
    End Function

    2. Create a .NET DLL and expose it as COM
    Public Class COMClass
    Public Function UseVBAClassAndD oSomething(ByVa l S as String, ByRef VBAClass as Object, ByRef RetVal as double) as Integer
    Dim R as Double
    VBAClass.DoSome thing("anything ", R)
    RetVal = R + 10
    UseVBAClassAndD oSomething = 0
    End Function
    End Class

    3. From MS ACCESS, CreateObject .NET DLL and pass a reference of the above class (say call it Class1) to a method in the .NET DLL

    Dim C as Class1
    Dim R as Double
    Dim O as Object
    Set C = New Class1
    Set O = CreateObject("M yNETDLL.COMClas s")
    Msgbox O.UseVBAClassAn dDoSomething("j ust a string", C, R)
    Set O = Nothing
    Set C = Nothing

    It works as intended but when the MS ACCESS app closes, MS ACCESS process is still runnning and you cannot close MS ACCESS.exe (unless you goto Taskbar and kill the process).

    Has anyone experienced the same? How did you resolve this? Thanks in advance
    Last edited by VaBa; Apr 10 '08, 03:21 AM. Reason: COMClass name change
Working...