Micro Focus QTP (UFT) Forums

Full Version: Data importing from excel using script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi ,

I needto enter the username, password value from external excel sheet by using script.
Howcan i write the script for this condition

A B
Username Password
tutorial tutorial
abc cde
12345 12345

I did something
Code:
set objExe= createobject("Excel.Application")
Set a=objExe.workbooks.open("     ")
Set b=a.worksheets("sheet1")


IT would be great if anyone suggests how do i write?
Code:
Set objXL = CreateObject("Excel.Application")
    objXL.Application.visible = true
    Set objWB = objXL.WorkBooks.Open(filePath)
    Set objWS = objXL.ActiveWorkBook.WorkSheets(workSheetName)
    'how many rows are used in the current worksheet
    rCount = objWS.UsedRange.Rows.Count
    
   'Considering u know the column number
    For row = 1 To rCount
          MsgBox objWS.Cells(row,column).Value
    Next
    objXL.Quit
    Set objXL = Nothing
    Set objWB = Nothing
    Set objWS = Nothing
Code:
dim xl
set xl=createobject("excel.application")

xl.workbooks.open "D:\Documents and Settings\320003992\Desktop\New Microsoft Excel Worksheet.xls"
xl.visible=true
xl.sheets("Sheet1").select

rc=xl.activeworkbook.sheets("Sheet1").usedrange.rows.count
msgbox rc

for i=1 to rc

a=xl.cells(i,"A").value
msgbox a
b=xl.cells(i,"B").value
msgbox b

next

xl.activeworkbook.save
xl.quit
set xl=nothing
This was excellent piece of code.Thanks very much.Hope my problem is solved.