Hi Armands,
You may not be able to get TestComplete and Excel to cooperate like that, I know I've had a lot of trouble trying to get TestComplete to step through an Excel file the way I needed it too. The solution I've used is to import the Excel file into Access and use queries instead. I created a dummy spreadsheet that I imported and using the following code read back all of column 7. (Data.mdb with the sheet becoming table User_Data)
Sub main
Call Test_Data("7")
End sub
Function Test_Data(column)
Dim Array_Test_Data(5)
x=0
For i = 1 To 6
For j = column To column
Array_Test_Data(x) = Get_Data(i,j)
x=x+1
Next
Next
for y = 0 to ubound(Array_Test_Data)
Log.Message(Array_Test_Data(y))
Next
Test_Data = Array_Test_Data
End Function
Function Get_Data(i,j)
Dim Qry
' Create a query
Set Qry = ADO.CreateADOQuery
' Specify the connection string
Qry.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source=C:\Data.mdb"
' Specify the SQL expression
Qry.SQL = "Select * FROM [User_Data] WHERE [User_Data].[ID] = :Num"
' Specify the parameter value
Qry.Parameters.ParamByName("Num").Value = i
' Execute the query
Qry.Open
' Process results and return the value to the calling routine
Qry.First
Get_Data = Qry.FieldByName(j).Value
Qry.Close
End Function
I hope this will help.