rhsou123
9 years agoContributor
Using Excel file with DDT driver in code
Hi,
This is my first Testcomplete script and I want to access to Excel file using DDT but I got this error message: " An Attempt to work with Closed Driver"
I verified my Excel, it is 32 bits and as what I said this my first connection.
This is my code:
In this script, I need to loop the sheet1 of the Excel file and verify if the value of the column "STP_Name" is different to "name1" and the value of the "Execute" column is "Y", if it is the case, display a message "Yeeeees".
Any help please, how can I solve this error ?
Sub execute() set xlDriver = DDT.ExcelDriver("C:\Script-Resources\BatchRun\filename.xls","Sheet1",true) xlDriver.First Value1=xlDriver.Value("Execute") Value2=xlDriver.Value("STP_NAME") Value1=xlDriver.ColumnName(ColumnIndex) Value2=xlDriver.ColumnName(ColumnIndex) while not xlDriver.EOF if value2 <> "name1" then if Value1 = "Y" then BuiltIn.ShowMessage("Yeeeeeees") else BuiltIn.ShowMessage("Noooooooo") end if else BuiltIn.ShowMessage("Environment file") end if xlDriver.Next wend end sub Sub Test1() Call execute() End sub
Thank you !
The problem is solved, I just tried with false instead of true and it works fine.