2 Replies - 1518 Views - Last Post: 25 January 2013 - 03:53 AM Rate Topic: -----

#1 sonalipatil311  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 23-November 12

how to close excel application open by vb.net code.

Posted 25 January 2013 - 02:55 AM

how to close excel application open by vb.net code. When I quit application in my code.. It still running in task manager.. this is my code

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet

xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")

.......................write in excel sheet..........

xlWorkBook.SaveAs(filepath, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue)
xlWorkBook.Close(True, misValue, misValue)
xlApp.Quit()

Is This A Good Question/Topic? 0
  • +

Replies To: how to close excel application open by vb.net code.

#2 maxrock  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 70
  • Joined: 13-September 09

Re: how to close excel application open by vb.net code.

Posted 25 January 2013 - 03:14 AM

This should work!

No errors recorded??

Regards,
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2877
  • View blog
  • Posts: 9,548
  • Joined: 12-December 12

Re: how to close excel application open by vb.net code.

Posted 25 January 2013 - 03:53 AM

xlApp = New Excel.ApplicationClass
'should be..
xlApp = New Excel.Application


An old page that discusses this.

excelApp.Workbooks.Close();      
excelApp.Quit();      
Marshal.ReleaseComObject(xlWorkbook);
Marshal.ReleaseComObject(xlSheets);
Marshal.ReleaseComObject(xlSheet);
Marshal.ReleaseComObject(excelApp);


http://stackoverflow...interop-objects

Good tutorial

This post has been edited by andrewsw: 25 January 2013 - 03:57 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1