Micro Focus QTP (UFT) Forums
Data importing from excel using script - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Data importing from excel using script (/Thread-Data-importing-from-excel-using-script)



Data importing from excel using script - vaigundamoorthy - 02-11-2009

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?


RE: Data importing from excel using script - Prafulla - 02-12-2009

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



RE: Data importing from excel using script - bfakruddin - 02-12-2009

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



RE: Data importing from excel using script - lit_73 - 05-19-2009

This was excellent piece of code.Thanks very much.Hope my problem is solved.