title: COM Object Cleanup
body: <p>I am instantiating a COM object from a VBA script in excel as defined in a C# dll. The C# class I instantiate has a finalizer that performs garbage collection, notably other MS Office objects it references, which I should see appear and disappear in the task manager.  In fact, the unit tests demonstrate that an Office process appears when the dll is called, and goes away when it is finished.</p>
  
  <p>When the dll is called from the VBA, I have noticed that the processes remain open after the VBA function ends, i.e. the object is notcleaned up after being called, which leads me to believe that VBA does not release the COM object.  </p>
  
  <p>My function looks something like this:</p>
  
  <pre><code>Function Raz(inp As String)
   Dim o: Set o = CreateObject("foo.bar")
   o.InputFields.FirstInput = inp
   o.Update
   Raz = o.OutputFields.FirstOutput
  End Function
  </code></pre>
  
  <p>I have added the following line at the end of the function in order to resolve the issue:</p>
  
  <pre><code>set o = Nothing
  </code></pre>
  
  <p>However, the resources in my COM process remain after execution and completion of my VBA script. How do I garbage collect my COM objects from VBA without manually creating a dispose call?</p>