12-10-2013, 06:30 PM
I have a open excel work sheet and i need to activate this sheet and paste values to it. I have written code to open a new excel sheet and paste values into sheet1. But not sure how to activate once again and paste values into sheet2 so on...
Right now, every time i close the excel and open once again
I receive Unknow run time error
Right now, every time i close the excel and open once again
Code:
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Visible = True
Set xlsWorkBook = xlsApp.Workbooks.Open("C:\Users\narayk\Desktop\Test.xlsx")
columncounter = JavaWindow("").JavaTree("").GetROProperty("columns_count")
For i=1 to columncounter-1
selectItem =JavaWindow("").JavaTree("").Getcolumnheader(i)
xlsWorkBook.Worksheets("sheet1").Cells(1,i).value=selectItem
next
'Activate the excel second time and paste values- not working
rowcount = JavaWindow("").JavaTree("").GetROProperty("")
For R=0 to rowcount-1
For C=0 to columncounter-1
counter = JavaWindow("").JavaTree("").GetColumnValue(R,C)
xlsWorkBook.Worksheets("sheet2").Cells(2,C).value=selectItem
Next
Next
I receive Unknow run time error