Excel won't quit from VB.NET

A

Atchoum

I've read zillions of threads on this and can't figure out why Excel process
is still running. Can someone help?

Private ExcelApp As Excel.Application
Private oBooks As Excel.Workbook

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateObject("Excel.Application")
Wb = ExcelApp.Workbooks.Open("C:\Book1.xls")

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

ExcelApp.Workbooks.Close() '(or Wb.Close)
ExcelApp.Quit

End Sub

I don't get why even after ExcelApp.Quit, Excel.exe still appears in task
manager...

Atchoum
 
G

Guest

I rearranged your code slightly and I don't get excel process still running
when I do it this way:
Private ExcelApp As Excel.Application
Private oBooks As Excel.Workbook

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
ExcelApp = New Excel.Application
ExcelApp.Visible = True
oBooks = ExcelApp.Workbooks.Open("C:\Book1.xls")

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button2.Click

ExcelApp.Workbooks.Close() '(or Wb.Close)
ExcelApp.Quit()

End Sub

HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top