reading text file does not advance

mwc0914

New Member
Joined
Sep 24, 2015
Messages
42
I have a text file of about 20 file names I generated from doing a shell dir command and placing the output in a text file.
I am reading the text file row by row and doing processing after each row read. It works fine for the first 6 rows or so, then on the next row read, it stops advancing to the next row.
My code is basically as follows in VBA


Dim objfso As Object
Dim dirlist_rcd As String
Dim txtstream As Object
Set objfso = CreateObject("Scripting.fileSystemObject")
Set txtstream = objfso.OpenTextFile(filepath & "dirlist.txt")

Do While Not txtstream.AtEndOfStream
dirlist_rcd = txtstream.ReadLine

....
processing...
...
Loop
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Update...I deleted the 7th record from the file, thinking maybe something wrong with that record. The code still does not advance after 6 rows.
I changed txtstream.ReadLine txtstream.readall and the entire file did read into txtstream. I have not tried splitting txtstream yet.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top