Looping through files in a folder

P

prepotency

I'm trying to loop through all the *.?XT files in the given folder
e.g. xyzcompany.#XT abccomopany.TXT etc..

My code is stuck in some sort of loop that crashes excel. I think i
comes from using the Dir() statement. See what you can glean:


MyFile = Dir(CurDir() & "\*.?XT")

Do While MyFile <> ""
Open MyFile For Input As #1

For i = 1 To 3
Line Input #1, txt
Next

... code that parses the file and gets some information ...

Close
MyFile = Dir() 'next file in the directory

Loop



so i can see that it's getting the information because it outputs th
information to my spreasheet but after it gets all the info it goe
into an infinite loop

thoughts?
 
P

prepotency

Figured it out. ROFL.

It's because my top part where I loop through 3 times needs a

If Not EOF(1) Then

but all the files in the directory have more than 3 lines in them. s
why is this necessary?

regards,
garret
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top