Micro Focus QTP (UFT) Forums
How To Capture Array Value into Excel Worksheet? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How To Capture Array Value into Excel Worksheet? (/Thread-How-To-Capture-Array-Value-into-Excel-Worksheet)



How To Capture Array Value into Excel Worksheet? - Studymode - 01-09-2018

Hi all,

I have been trying all various methods to get the run time value from the application to an array and then from the array to excel worksheet. Here is my script, please if you can educate me on what it is that i am doing wrong here. 

  systemutil.Run "iexplore.exe""www.edmunds.com/calculators"
Set MyBrowser = Browser("Micclass:=Browser""CreationTime:=0""Title:=.*").Page("Micclass:=Page""CreationTime:=0""Title:=.*") 

Set MyXL = CreateObject ("excel.application")
    MyXl.workbooks.open "C:\Users\User\Desktop\ArrayPracticeExcel.xlsx"
    MyXl.application.visible = True 
set MySheet = MyXl.activeworkbook.worksheets ("Sheet1") 
    
Dim oDesc
Set oDesc = Description.Create
set oDesc = Description.Create 
    oDesc("Micclass").Value = "WebEdit"
    oDesc("Name").Value = "calc_default_value"
    oDesc("html tag").Value = "INPUT"
    
    set Obj = MyBrowser.ChildObjects(oDesc)
    msgbox Obj.Count 
    

Dim i,x,Arr1()

For i = 0 To obj.count-1
    x = obj(i).GetRoProperty("html id")
        msgbox x
        ReDim preserve arr1(obj.count-1)
        arr1(i) = x 
        
Next
ReDim preserve arr1(obj.count-1)
For j = 0 To ubound(Arr1)
    mysheet.cells(i,"A").Value = arr1(j)
Next

This Line above only adds the value to the 4th row and nothing else. I wan the script to be able to capture the value and put them into row 1,2,3,and 4. Please any help would be greatly appreciated.