Jump to content
Xtreme .Net Talk

tylee

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by tylee

  1. Here is my working code which opens the file, changes it and saves it. I finally got it to destroy the process with the help of the previous post. Dim MyExcel As New Excel.Application() Dim oWorkbooks As Excel.Workbooks = MyExcel.Workbooks Dim theWorkbook As Excel.Workbook = oWorkbooks.Add Dim oSheet As Excel.Worksheet theWorkbook = oWorkbooks.Open("C:\TEST.xls") oSheet = MyExcel.ActiveSheet() 'ALTER THE WORKSHEET HERE theWorkbook.Save() theWorkbook.Close() MyExcel.Quit() oSheet = Nothing theWorkbook = Nothing oWorkbooks = Nothing MyExcel = Nothing GC.Collect() GC.WaitForPendingFinalizers()
  2. Hi I have a .net project written in vb.net and i am having a problem killing ALL instances of the excel process in the task manager. I had this problem with a windows service written in vb.net but I have managed to fix that problem but the same code doesn't fix the problem I am having in my website The Code: Dim exObj As New Excel.Application() Dim exWorksheet As Excel.Worksheet Dim exWorkbook As Excel.Workbook exWorkbook = exObj.Workbooks.Open(("Template.xlt") exWorksheet = exWorkbook.Worksheets(1) 'Code in here which writes to the excel file and saves it for furture use 'attempts to close the excel process exWorkbook.Close() exObj.Workbooks.Close() exObj.Application.Quit() exObj.Quit() exWorksheet = Nothing exWorkbook = Nothing exObj = Nothing GC.Collect() GC.WaitForPendingFinalizers() if anyone can help it would be much appreciated
  3. I know this might be a bit of overkill but i got this to work in .net with it opening the excel file writing the value "Something New" and then closing it ( and destorying the Excel process in the task manager) Hope this works for you Dim Xl As New Excel.Application() Dim Xlb As Excel.Workbook = Xl.Workbooks.Open("C:\Kk.xls") Dim Xls As Excel.Worksheet = CType(Xlb.Worksheets(1), Excel.Worksheet) TextBox1.Text = Xls.Cells(1, 1).value Xls.Cells(1, 1).Value = "Something new" Xlb.Save() 'Changed Code exWorkbook.Close() exObj.Workbooks.Close() exObj.Application.Quit() exObj.Quit() exWorksheet = Nothing exWorkbook = Nothing exObj = Nothing GC.Collect() GC.WaitForPendingFinalizers()
×
×
  • Create New...