Contributions
Read and Write into Excel
Hi ALL I am running into some problems trying to read and write to an excel file. I have data I am reading for a data driven test and I would like to write in the last column the result of the test pass/fail. I am using this code to cycle through the test data I want to use to run the test Set xlsDriver = DDT.ExcelDriver("c:\Data.xls","Sheet1") While Not xlsDriver.EOF() Project.Variables.Data1 = xlsdriver.Value(0) Project.Variables.Data2 = xlsdriver.Value(1) Project.Variables.Data3 = xlsdriver.Value(2) Call RunTest xlsDriver.Next() 'Goes to the next record WEnd DDT.CloseDriver("c:\Data.xls") In the function “RunTest” I want to be able to write back to the same file the test results in the last column pass/fail. I tried to open the file to write to it this way FName = "c:\Data.xls" Set ExcelApp = Sys.OleObject("Excel.Application") ExcelApp.DisplayAlerts = False If (Utilities.FileExists(FName)) Then Set Logbook = ExcelApp.Workbooks.Open(FName) Else Set Logbook = ExcelApp.Workbooks.Add Call Logbook.SaveAs(FName) End If Set Sheet = Logbook.Sheets(1) Sheet.Cells(1,4) = "PASSED" But since Excel is already open, this failed. Since it is already open, I tried setting xlsdriver.Value(3) = “PASSED” but TC did not like this If I close the driver “ DDT.CloseDriver("c:\Data.xls")” So I can use the “Set ExcelApp = Sys.OleObject("Excel.Application") “ command, I then lose my place in the While Not xlsDriver.EOF() and it run the same test in an infinite loop If I only use the “Set ExcelApp = Sys.OleObject("Excel.Application") “ commands, I do not have an .EOF option to cycle through the test data any ideas how I can code this to read and write at the same time? Any assistance appreciated Thanks in advance Eric20KViews0likes3Comments