Excel Scripts Examples: Visit: For QTP Information
Excel Scripts Examples: Visit: For QTP Information
www.gcreddy.com
1) Dim objexcel
3) objexcel.Visible = True
4) objexcel.Workbooks.add
6) objexcel.ActiveWorkbook.SaveAs(“f:exceltest.xls”)
7) objexcel.Quit
1) Set myExcel=Createobject(“Excel.Application”)
3) Set mySheet=myFile.worksheets(“Sheet1″)
4) Rows_Count=mySheet.usedrange.rows.count
5) For i= 1 to Rows_Count
6) Agent=mySheet.cells(i,”A”)
7) pwd=mySheet.Cells(i,”B”)
1
Visit: www.gcreddy.com for QTP Information
9) Dialog(“Login”).Activate
14) Next
objExcel.Visible = True
Else
End If
Next
objWorkbook1.close
objWorkbook2.close
objExcel.quit
2
Visit: www.gcreddy.com for QTP Information
set objExcel=nothing
Datatable.AddSheet “gcreddy”
n=datatable.GetSheet (3).GetRowCount
For i= 1 to n
Datatable.SetCurrentRow(i)
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Password:”).Set datatable(“pwd”,3)
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Close
Next
Example 2):
Datatable.AddSheet “gcreddy”
n=datatable.GetSheet (3).GetRowCount
For i= 1 to n
Datatable.SetCurrentRow(i)
VbWindow(“Form1″).Activate
VbWindow(“Form1″).VbEdit(“val1″).Set datatable(“V1″,3)
VbWindow(“Form1″).VbEdit(“val2″).Set datatable(“V2″,3)
3
Visit: www.gcreddy.com for QTP Information
VbWindow(“Form1″).VbButton(“ADD”).Click
ares=VbWindow(“Form1″).VbEdit(“res”).GetROProperty (“text”)
If eres=ares Then
datatable(“res”,3)=pass
else
datatable(“res”,3)=fail
End If
Next
(“C:ScriptsNew_users.xls”)
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = “”
intRow = intRow + 1
Loop
objExcel.Quit
4
Visit: www.gcreddy.com for QTP Information
objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Font.Size = 24
objExcel.Cells(1, 1).Font.ColorIndex = 3
Const xlAscending = 1
Const xlDescending = 2
Const xlYes = 1
objExcel.Visible = True
objExcel.Visible = True
Set objWorkbook = _
objExcel.Workbooks.Open(“C:ScriptsSort_test.xls”)
objRange.Sort objRange2,xlAscending,objRange3,,xlDescending, _
objRange4,xlDescending,xlYes
5
Visit: www.gcreddy.com for QTP Information
www.gcreddy.com