I am creating an instance of a COM object from a VBA script in excel as defined in the C # dll. In the instance of the C # class, there is a finalizer that collects garbage, in particular other MS Office objects that it refers to, and I have to see and disappear in the task manager. In fact, unit tests demonstrate that when the dll is called, the Office process appears and disappears when it is completed.
When the DLL is called from VBA, I noticed that the processes remain open after the VBA function is completed, that is, the object is not cleared after the call, which makes me think that VBA is not freeing the COM object.
My function looks something like this:
Function Raz(inp As String)
Dim o: Set o = CreateObject("foo.bar")
o.InputFields.FirstInput = inp
o.Update
Raz = o.OutputFields.FirstOutput
End Function
I added the following line at the end of the function to solve the problem:
set o = Nothing
COM- VBA script. COM VBA ?