+ Reply to Thread
Results 1 to 3 of 3

make a list of files in a directory

  1. #1
    GFN
    Guest

    make a list of files in a directory

    Is there a way for excel to list the files in a directory including
    subdirectories.



  2. #2
    Rowan
    Guest

    RE: make a list of files in a directory

    from Excel help

    Set fs = Application.FileSearch
    With fs
    .LookIn = "C:\Documents and Settings\rdrummon\Desktop"
    .SearchSubFolders = True
    .Filename = "cmd*"
    If .Execute() > 0 Then
    MsgBox "There were " & .FoundFiles.Count & _
    " file(s) found."
    For i = 1 To .FoundFiles.Count
    MsgBox .FoundFiles(i)
    Next i
    Else
    MsgBox "There were no files found."
    End If
    End With

    this example searches for all files starting with cmd, take out the line
    ..Filename = "cmd*"
    to search for all files.

    Hope this helps
    Rowan


    "GFN" wrote:

    > Is there a way for excel to list the files in a directory including
    > subdirectories.
    >
    >


  3. #3
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    Sub ListFiles02(FileDir)

    'Using FileSearch to list the files in a directory

    Dim i As Integer

    i = 1

    With Application.FileSearch

    .NewSearch
    .LookIn = FileDir
    .FileName = "*.*"
    .SearchFolders = False
    .Execute

    For i = 1 To .FoundFiles.Count

    Range("A" & i).Value = .FoundFiles(i)
    Range("B" & i).Value = FileLen(.FoundFiles(i))
    Range("C" & i).Value = FileDateTime(.FoundFiles(i))

    Next

    End With

    End Sub

+ 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