List of .xls files in directory

  • Hey is there any way to get a list of filenames into VBA from a specific directory?
    for example all files in directory c:\my documents\excel?

  • Re: List of .xls files in directory


    I've used this snippet to open all files in a directory. The line I stated should give you the filenames of each file in a directory that you could store however you'd like. Definitely some extra code in there, but you should be able to salvage something from it.


  • Re: List of .xls files in directory


    Somehow i get an error on this Workbooks.Name line. what's wrong with it?



    Got it! sorry :) Stupid me :)))
    THANKS A LOT!!!

  • Re: List of .xls files in directory


    Code doesn't work with Excel 2007, so I was going to use code from SMC on an earlier thread:http://www.ozgrid.com/forum/showthread.php?t=65530
    How do I add code to search sub-folders, as in Application.File Search ability: .SearchSubFolders = True


    Private Sub Workbook_Open() 'Upon opening the file, do this:
    'First action: Create a worksheet with names of all files in \\Ssi08\sys1\DOCS

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!