LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default readall gives error for last file from getfolder().files

Cannot figure out why this happens only on the lsat file found by the
getfolders().files. Any help would be great!!

Set apps = fso.getfolder("c:\ds_wind").Files
Do
Set apps = fso.getfolder("c:\ds_wind").Files
Loop While apps.Count < (Range("d1") - Date + 3)
For Each Filename In apps
Set fs = fso.opentextfile(Filename)
txtstring = ""
txtstring = fs.readall
fs.close
txtstring = Right(txtstring, Len(txtstring) - InStr(txtstring, "R:") - 18)
txtstring = Left(txtstring, InStr(txtstring, "TOTAL:") - 1)
txtarray = Split(txtstring, " ")
txtarray2 = ""
For i = 0 To UBound(txtarray)
txtarray(i) = Trim(txtarray(i))
txtarray(i) = Replace(txtarray(i), Chr(10), "", 1, -1,
vbBinaryCompare)
txtarray(i) = Replace(txtarray(i), Chr(13), "", 1, -1,
vbBinaryCompare)
If txtarray(i) < "" And txtarray(i) < "." Then
txtarray2 = txtarray2 + "," + txtarray(i)
End If
Next
txtarray = Split(txtarray2, ",")
filedate = "" & txtarray(1) & ""
i = 9
If Range("a5").Value = "" Then
rwidx = 5
Else
rwidx = Range("a4").End(xlDown).Row + 1
End If
While i < UBound(txtarray)
Cells(rwidx, 1) = "'" & filedate
Cells(rwidx, 2) = "'" & txtarray(i)
Cells(rwidx, 3) = "'" & txtarray(i + 5)
Cells(rwidx, 4) = "'" & txtarray(i + 6)
Cells(rwidx, 5) = "'" & txtarray(i + 9)
i = i + 10
rwidx = rwidx + 1
Wend
Next
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File error when opening some Excel files serope Excel Discussion (Misc queries) 0 January 30th 09 07:04 PM
EXCEL FILES ARE NOT OPENING ERROR IS this file is not in recogniz Umar Aftab Excel Discussion (Misc queries) 0 June 7th 07 02:18 PM
how to default WritePassword under excel workbook property for any files as long as those files are the offsprings of the parent file George Excel Programming 0 October 5th 06 04:14 PM
Trying to open Excel/Word files error message "Unable to read file RobM Excel Discussion (Misc queries) 1 February 7th 05 08:11 PM
Need a "GetFolder method" Helge V. Larsen[_2_] Excel Programming 5 December 11th 03 02:19 PM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"