Hi,

I am trying to read an excel file with below function and I am getting 
"Script Out of range" error message, However when I tried the same code on 
a friends machine it worked fine.

Can anybody in this group figure out the issue, that would be a great help.

'''''''''''''''excel read function''''''''''''''''''''''''''''
Function xlread(xlpath,xlsheet,xlr,xlc)
   Dim myxlapp,myxlsheet
   Set myxlapp=createobject("Excel.Application")
   myxlapp.Workbooks.Open xlpath
   Set myxlsheet=myxlapp.ActiveWorkbook.Worksheets(xlsheet)
   xlread=myxlsheet.cells(xlr,xlc)
   print xlread
myxlapp.ActiveWorkbook.Close
myxlapp.Quit
Set myxlsheet=nothing
Set myxlapp=nothing
End Function
**************************************************

On Friday, 20 March 2009 00:18:30 UTC+5:30, [email protected] wrote:
>
> Hi
>
> I have a scenario like the one mentioned below.
>
> 1. I have a dynamic array say textlines()
> 2. I am reading a txt file content, line by line and need to store it in 
> the above mentioned dynamic array
> 3. i need to calculate the total number of lines in the file
>
> To accomplish this i have coded like this, but which doesnt work??!!!!
>
>
> Dim tempfile, textlines(),i,fso
>
>  Const ForReading = "1"
>
> i = 0
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set tempfile= fso.OpenTextFile(  "C:\file.txt", ForReading )
>
> Do Until tempfile.AtEndofStream 
>       textlines(i) = tempfile.ReadLine()
>       i = i + 1
>   
>  Loop
>
>  msgbox(i)
>
> Please help me with the solution. Also how to return two values("i" and 
> textline()), if this is to be done in a function????
>
> Waiting for the reply
> Regards
> Suresh S
>

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to