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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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,216,518
Messages
6,131,121
Members
449,624
Latest member
MandlaMan

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