+ Reply to Thread
Results 1 to 7 of 7

dir all files in a folder and sub folders

  1. #1
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    dir all files in a folder and sub folders

    Hi.

    Trying to write a macro that will dirr a files in a selected folder and write all filenames in a list.

    Have completed a macro that will dirr all files from ONE map but it doesn't write the names of files in the subfolders under the selected map.

    The code so far is :

    Please Login or Register  to view this content.
    Would be really greatful if someone could help me with a code that would dir all files in the selected dir + all files in dirs under that one !


    Thanks in advance !

    //

    Per

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    re: dir all files in a folder and sub folders

    Hello Pero,

    This macro will list either all the files in single directory or list all files in the directory and the subfolders. In columns "A - F" the following file information is listed: Name, Path, Size, Date Created, Date Last Modified, File Owner. You can change thor delete these as needed.
    Please Login or Register  to view this content.
    Example
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    re: dir all files in a folder and sub folders

    Thank you for the quick response !

    Tho I can't get it work.

    When I copy this text into a module its not shown as a macro in the macro list.

    What could be wrong ??

    Thanks !

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    re: dir all files in a folder and sub folders

    Hello Pero,

    You didn't do anything wrong. Any Sub or Function that takes arguments is automatically hidden from the macro list by Excel. Here is a macro that will be visible. Change the path to the one you want.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-20-2009
    Location
    Stockholm,Sweden
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: dir all files in a folder and sub folders

    Thanks again for the help !

    The macro is now visible in the macro list but now when i try to run the macro it says "Sub or function could not be defined"
    And the text marked yellow text is:

    Please Login or Register  to view this content.
    I also want the macro to start at J13 to O13 instead of A:F.
    Also I want the filepath be be a variabel that is red from the column C3.

    Sry for my lack of knowlage in this matter, I'm trying to learn.

    Many many thanks !

    My code right now is:
    Please Login or Register  to view this content.

    Thanks in advance !


    // Per
    Last edited by Pero; 09-09-2009 at 06:00 PM.

  6. #6
    Registered User
    Join Date
    09-19-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: dir all files in a folder and sub folders

    Hi,

    I think the poster forgot to post the codes for the Get Owner macro.

    You can find it here:

    http://www.excelforum.com/excel-prog...in-folder.html

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: dir all files in a folder and sub folders

    Hello Pero and Jubinell,

    Excellent catch on the missing macro Jubinell! I wrote the code and completely missed the obvious. Here is the full code with the corrections.

    Calling Macro
    Please Login or Register  to view this content.
    List Files In Folder Macro
    Please Login or Register  to view this content.
    Get File Owner Macro
    Please Login or Register  to view this content.

+ 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