+ Reply to Thread
Results 1 to 2 of 2

Looping through files in a folder

Hybrid View

  1. #1
    Registered User
    Join Date
    06-09-2005
    Posts
    15

    Looping through files in a folder

    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 it 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 the information to my spreasheet but after it gets all the info it goes into an infinite loop

    thoughts?

    G

  2. #2
    Registered User
    Join Date
    06-09-2005
    Posts
    15
    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. so why is this necessary?

    regards,
    garrett

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1