>>Imports Microsoft.Office.Interop >>Public Class fwExcel >> Implements IDisposable >> Public oApp As New Excel.Application >> Public oWBs As Excel.Workbooks >> Public oWB As Excel.Workbook >> >> Dim thisThread As System.Threading.Thread >> Dim lQuit As Boolean = True >> Dim lDisposed As Boolean = False >> >> Sub New() >> Me.thisThread = System.Threading.Thread.CurrentThread >> Me.originalCulture = thisThread.CurrentCulture >> Me.thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US") >> Me.oWBs = Me.oApp.Workbooks >> Me.oApp.DisplayAlerts = False >> End Sub >> Sub Dispose() Implements IDisposable.Dispose >> If Me.lDisposed Then Exit Sub >> If lQuit Then Me.oApp.Quit() >> Me.releaseObject(Me.oWB) >> Me.releaseObject(Me.oWBs) >> Me.releaseObject(Me.oApp) >> Me.thisThread.CurrentCulture = Me.originalCulture >> Me.lDisposed = True >> End Sub >> Protected Overrides Sub finalize() >> Me.Dispose() >> End Sub >> Public Sub releaseObject(ByVal o As Object) >> If o Is Nothing Then Exit Sub >> Runtime.InteropServices.Marshal.FinalReleaseComObject(o) >> o = Nothing >> End Sub >>Hmm. You don't distinguish between a call made to Dispose() via the finalizer and via user code. Not sure whether it's important in this case but, in general, the state of objects during finalize cannot be relied on.