Looping file count limit?

irish634

Registered User.
Local time
Yesterday, 19:43
Joined
Sep 22, 2008
Messages
230
This has been driving me batty for a few days.

I am trying to perform a simple task and loop through a folder to retrieve file names.

The problem is I only get 199 files and there are over 400 in the folder.

Here is my latest code:
Code:
Sub File_Import()

    Dim FSO As FileSystemObject
    Dim sFolderPath As String
    Dim files_collection, filecount, filename, folder, i, file

    Set FSO = CreateObject("Scripting.FileSystemObject")
    sFolderPath = CurrentProject.path & "\"


    Set folder = FSO.GetFolder(sFolderPath)

    ' get a collection of all the files in the folder
    Set files_collection = folder.Files
    
    
    For Each file In files_collection
        filename = file.Name
        Debug.Print filename
    Next

    Set FSO = Nothing
    Set folder = Nothing
    Set files_collection = Nothing


End Sub

What am I missing that will let me retrieve ALL the file names regardless of how many files are in the folder?

Thanks,
Craig
 
Don't use this line as is:

Dim files_collection, filecount, filename, folder, i, file

Declare them with the right types

Dim files_collection As Collection
Dim filecount As Long
Dim filename As String
etc.
 
The immediate window can only display about 200 lines, if you need to list more than this you need to print the contents to a text file, save the entries to a table, or print them to a textbox on a form.
 
The immediate window can only display about 200 lines, if you need to list more than this you need to print the contents to a text file, save the entries to a table, or print them to a textbox on a form.

No wonder I was only getting a partial list. As much as I use the immediate window, I probably should have known that. Thanks.
 

Users who are viewing this thread

Back
Top Bottom