oprogrammer Posted September 17, 2008 Posted September 17, 2008 I am using BackgroundWorker and create a reference to excel. Problem is I can not seem to release the reference. It still shows up in task manager and does not release until the application closes. Any suggestions? Quote
Administrators PlausiblyDamp Posted September 17, 2008 Administrators Posted September 17, 2008 What code are you using to release Excel? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
oprogrammer Posted September 17, 2008 Author Posted September 17, 2008 xlApp.Quit() xlApp = Nothing Normally this works, but I can not seem to get it to work with a new thread with backgroundworker. Code Example 1: This code within a module works. Viewing task manager excel starts and exits. I use this all the time. Sub mExcelReport() Dim xlApp as New Excel.Application Dim xlSheet as New Excel.WorkSheet xlApp.Workbooks.Add xlSheet = xlApp.ActiveSheet xlSheet.Range("A2").Value = "Hello" xlApp.Quit() xlApp = Nothing End Sub Code Example 2: When I run it with Backgroundworker the Excel Reference does not release. Excel is still visible with tasks manager. This is causing issues when other process run. Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork mExcelReport() End Sub Sub mExcelReport() Dim xlApp as New Excel.Application Dim xlSheet as New Excel.WorkSheet xlApp.Workbooks.Add xlSheet = xlApp.ActiveSheet xlSheet.Range("A2").Value = "Hello" xlApp.Quit() xlApp = Nothing End Sub Any ideas? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.