Working with multiple excel files

Working with multiple excel files

Option Explicit
Dim objExcel, myFile1, myFile2, mySheet1, mySheet2, InputRowCount, i, vErrMsg
Set objExcel = CreateObject(“Excel.Application”)
Set myFile1 = objExcel.Workbooks.Open (“C:UsersLiaquatDesktopInputDataLogin.xls”)
Set myfile2 = objExcel.Workbooks.Open (“C:UsersLiaquatDesktopOutputData.xls”)
Set mySheet1 = myFile1.Worksheets(1)
Set mySheet2 = myFile2.Worksheets(1)

InputRowCount = mySheet1.UsedRange.Rows.Count
‘msgBox InputRowCount

‘Reading File from Input Excel File
For i = 2 To InputRowCount Step 1
‘    mySheet1.SetCurrentRow(i)
SystemUtil.Run “C:Program Files (x86)HPUnified Functional Testingsamplesflightappflight4a.exe”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set mySheet1.Cells(i, 1)
Dialog(“Login”).WinEdit(“Password:”).Set mySheet1.Cells(i, 2)
Dialog(“Login”).WinButton(“OK”).Click
If Window(“Flight Reservation”).Exist(3) Then
Window(“Flight Reservation”).Close
mySheet2.Cells(i, 3) = “Login Successful -Passed”
Else
mySheet2.Cells(i, 3) = “Login UnSuccessful -Failed”

vErrMsg = Dialog(“Login”).Dialog(“Flight ResDialog”).Static(“ErrMsg”).GetROProperty(“text”)

If Dialog(“Login”).Dialog(“Flight ResDialog”).Exist(4) Then
Dialog(“Login”).Dialog(“Flight ResDialog”).Activate
Dialog(“Login”).Dialog(“Flight ResDialog”).WinButton(“OK”).Click
Dialog(“Login”).WinButton(“Cancel”).Click
mySheet2.Cells(i, 4) = vErrMsg
End If
End If
Next

 

Comments