Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to enter values into excel which is already open using QTP
#1
Not Solved
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


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
Reply
#2
Not Solved
Probably it should be,
Code:
For C=1 to columncounter-1
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help for copying values from one excel to another excel vinodhiniqa 0 1,359 07-06-2017, 05:33 PM
Last Post: vinodhiniqa
  How import final calculated values by cell formula from Excel not the formula itself. qtped 1 4,851 01-17-2017, 04:05 PM
Last Post: sagar.raythatha
  Unable to pass "Enter" Key through Sendkeys Lavanya N 1 4,157 07-24-2015, 02:17 PM
Last Post: Lavanya N
  QTP does not record the first step of open filight reservation application. Blossoms 9 17,731 07-20-2015, 05:50 PM
Last Post: AJAJ
Smile Importing Excel sheet - Reference Values are not recognized michiusa69 3 7,877 01-23-2015, 02:36 AM
Last Post: lkng2001

Forum Jump:


Users browsing this thread: 1 Guest(s)