title: VB.Net, modify existing Excel instead of replacing, and closeing the call properly
body: <p>I have been researching and testing for three days on this problem.  I have tried variations of codes that I have seen on other sites and which I have found here as well.  I have looked at the following sites for inspiration:<a href="https://stackoverflow.com/questions/16689216/append-data-in-existing-excel-file-in-vb-net">Appending data in Excel</a>;<a href="https://stackoverflow.com/questions/15307021/how-to-append-data-to-existing-excel-file-using-vb-net">How to Append in Excel</a>;<a href="http://support.microsoft.com/kb/247412" rel="nofollow noreferrer">Methods for transferring to Excel</a>;<a href="http://www.dreamincode.net/forums/topic/243741-using-excel-in-vbnet/" rel="nofollow noreferrer">Using Excel in VB Net</a>;and a whole host of other sites.  </p>
  
  <p>I have several issues that I am trying to work out on my very first program.  With the tools above I have learned to validate user input and apply it to an Excel workbook.  However, every time I debug after making a change while trying to create a resolution, Excel always asks if I want to replace the existing file.  I do not.  I want to add data retrieved from each instance of when the program is run and replace the previous data.</p>
  
  <p>How do I add new data without replacing the existing workbook?  Thank you for your time, consideration, and any advice.</p>
  
  <pre><code>Imports Excel = Microsoft.Office.Interop.Excel
  </code></pre>
  
  <p>Public Class frmLocationECS</p>
  
  <pre><code>'Launches the first stage of the tracking process and removes four characters of the word item to populate the labels with the correct parts at each location.
  Private Sub frmLocationECS_Load(sender As Object, e As System.EventArgs) Handles Me.Load
      For Each ctrl As Control In TableLayoutPanel1.Controls
          If ctrl.Name.StartsWith("Item") And TypeOf ctrl Is Item Then
              CType(ctrl, Item).Title(ctrl.Name.Remove(0, 4))
          End If
      Next
  End Sub
  'Closes the current form and moves the user to the next location.
  Private Sub BtnNext_Click(sender As System.Object, e As System.EventArgs) Handles BtnNext.Click
  
      'Declare an instance of Excel and it's current path.  Data enterd by user is to be saved in the existing Excel workbook.
      Dim xlApp As New Excel.Application
      Dim xlWorkBook As Excel.Workbook
      Dim xlWorkSheet As Excel.Worksheet
      'Dim misValue As Object = System.Reflection.Missing.Value
      'Dim milkStart As Date = Now
  
      xlApp.Workbooks.Open("C:\IOtestsVB\TestWrite.xlsx")
      'xlApp = CreateObject("Excel.Application")
      xlWorkBook = xlApp.ActiveWorkbook
      xlWorkSheet = xlWorkBook.ActiveSheet
      'xlWorkSheet.Cells(2, 1) = "Plates (ECS)"
      'xlWorkSheet.Cells(2, 2) = "Inks (ECS)"
      'xlWorkSheet.Cells(2, 3) = "Chambers (ECS)"
      'xlWorkSheet.Cells(2, 4) = "Cores (ECS)"
      'xlWorkSheet.Cells(2, 5) = "Other (ECS)"
      'xlWorkSheet.Cells(1, 1) = milkStart
      xlWorkSheet.Cells(3, 1) = ItemPlates.Value
      xlWorkSheet.Cells(3, 2) = ItemInks.Value
      xlWorkSheet.Cells(3, 3) = ItemChambers.Value
      xlWorkSheet.Cells(3, 4) = ItemCores.Value
      xlWorkSheet.Cells(3, 5) = ItemOther.Value
      xlWorkBook.Save()
      xlApp.Workbooks.Close()
      'xlWorkBook.SaveAs("C:\IOtestsVB\" &amp; Now.ToString("HHmmss.xlsx"))
      xlApp.Quit()
      frmTest.ShowDialog()
      Me.Close()
  End Sub
  </code></pre>
  
  <p>End Class</p>