How can I call System.Runtime.InteropServices.Marshal.ReleaseComObject from within an Excel 2007 VBA module
问题 I want to call System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) on some 3rd party COM objects that I've instantiated in my VBA code, from my workbook close event, something like the following: Public Sub disconnect(obj As Variant) Dim refs As Long refs = 0 If Not obj Is Nothing Then Do refs = System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) Loop While (refs > 0) End If End Sub However, I get a compile error: invalid qualifier with the System highlighted with the above