Hai all,
I'm trying to link excel from vb.net to do data read & write. I'm able to do the linking but my problem is, i can't conncet to a particular worksheet.
This is my coding....
In my above coding label's value is moved to my "first" worksheet...but the the text array value are not moved to the "first" worksheet. It goes to the active worksheet (which is "third").Code:Dim oExcel As New Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet Dim R1 As Excel.Range oBook = oExcel.Workbooks.Open("c:\temp\new1.xls") oSheet = oBook.Worksheets("first") ' 3 worksheets 1.First, 2.Second, 3.Third oSheet.Range("A2").Value = Label1.Text oExcel.Range("C8:D19").Select() R1 = oExcel.Selection For i = 1 To 12 For j = 1 To 2 R1(i, j).value = Txtp(i,j).Text Next Next oBook.Save() oBook.Close() oBook = Nothing oExcel.Quit() oExcel = Nothing
I know that it is bcos of Oexcel.selection...i tried as osheet.selection but error occoured...dont know what to do????
I'm stucking with this...anybody can help me???
I appreciate the quick response...
Thanks in advance
Regards,
Hems.




Reply With Quote