Quality is delighting customers
Example scenario: If there a Notepad Having 2 columns for User names, Passwords, here we wants to Export these columns to Excel sheet. how.........?
Condition: User name should be in first column, then Password
Need Qtp Script for this...........Kindly Help me.............?
Tags:
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFSO.OpenTextFile("E:\sample.txt", 1)
Do Until oTxtFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = oTxtFile.ReadLine
i = i + 1
Loop
oTxtFile.Close
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("E:\sample.xlsx")
Set objWorksheet = objWorkbook.Worksheets("sheet1")
objWorksheet.Activate
objExcel.Application.Visible = True
j = 1
For i = 0 To ubound(arrFileLines)
k = 1
txt = split(arrFileLines(i)," ")
objExcel.Cells(j, k).Value = txt(0)
k = k + 1
objExcel.Cells(j, k).Value = txt(1)
j = j + 1
Next
objExcel.Application.Quit
Thanks mohan...
Hi Mohan,
Can u Explain below lines:
Redim Preserve arrFileLines(i)
arrFileLines(i) = oTxtFile.ReadLine
i = i + 1
AND
j = 1
For i = 0 To ubound(arrFileLines)
k = 1
txt = split(arrFileLines(i)," ")
objExcel.Cells(j, k).Value = txt(0)
k = k + 1
objExcel.Cells(j, k).Value = txt(1)
j = j + 1
© 2021 Created by Quality Testing.
Powered by