So I am trying to make a program in Visual Basic 2010 with a form so that every time the form is entered it will add another row of data to an excel spreadsheet. With the code I am currently using, a new spreadsheet is created every time I run the code, which is not what I want.
This is my current code, which I found through surfing the internet.
Thank you, and any help is greatly appreciated.
This is my current code, which I found through surfing the internet.
Thank you, and any help is greatly appreciated.
Code:
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
'Start a new workbook in Excel
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "Match Number"
oSheet.Range("B1").Value = "Team Name"
oSheet.Range("A1:B1").Font.Bold = True
oSheet.Range("A2").Value = matchNumber.Text
oSheet.Range("B2").Value = teamNumber.Text
'Save the Workbook and Quit Excel
oBook.SaveAs("C:\NewScouting\Book1.xls")
oExcel.Quit()