Professional Documents
Culture Documents
How Do I Read/write Excel Cell Data To Textbox & Visaversa
How Do I Read/write Excel Cell Data To Textbox & Visaversa
Well since you're copying data from the worksheet, I'm guessing its not a "new" worksheet.
But you have to declare the application, workbook, and worksheet that you are trying to get
data from
Code:
Dim excelApp As New Microsoft.Office.Interop.Excel.Application
Dim excelBook As Microsoft.Office.Interop.Excel.Workbook
Dim excelSheet As Microsoft.Office.Interop.Excel.Worksheet
excelBook = excelApp.Workbooks.Open("path")
excelSheet = excelBook.Worksheets(1)
'Now that you have your worksheet you can do your data manipulation
Textbox1.Text = excelSheet.Range("A1").Text
'or to edit
excelSheet.Range("A1").Text = Textbox1.Text
excelBook.Close
excelApp.Close