+ Reply to Thread
Results 1 to 6 of 6

Files within Multiple SubFolders and SubFolders Within It

  1. #1
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Question Files within Multiple SubFolders and SubFolders Within It

    Hey Guys,

    In need of some assistance. Basically, my objective is to get the list of files inside a particular directory. Directory includes many subfolders and inside those we again have 'n' number of folders. Am able to successfully get the file list if they in the parent or within 1-level subfolders. I need to get the list of files from 'n' number of levels of directory.

    Please Login or Register  to view this content.

    Thing is, I don't have pre-defined knowledge of how many levels it could be as it is defined by the users. With my above code, I know I'll have to repeat the loop for SubFolders and Files in them to the times the levels available. So I just need to know how many times, I'll have to loop or so..

    Am very much fond of new thoughts and suggestions if something better hit your heads.. Open for thoughts!
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Files within Multiple SubFolders and SubFolders Within It

    See if this helps...

    Add a filespec ('c:\temp\*.xl*' for example) in A1 of a blank sheet. All matching files will be returned in Col B and run the code.

    It does open another blank window on screen - unfortunately this cannot be hidden, but it should disappear fairly quickly depending on how many files are found.
    Please Login or Register  to view this content.
    If you think this is suitable, it would be easy to split out/determine the actual information you need.
    Last edited by cytop; 09-16-2013 at 05:50 AM. Reason: Typo

  3. #3
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Files within Multiple SubFolders and SubFolders Within It

    Hey Cytop,

    Thanks much for your response. Idea was good to get the count for the folders but really that CMD window is one annoying thing that needs to be closed everytime... :p

    I've worked out on my codes and am able to get my answers. I've used recursive method to get it work. But its running a bit slow as its calling the function again and again, plus, considering the amount of search its making in the disk. (I must say, I hate loops!! )

    Following is my updated code.

    Please Login or Register  to view this content.
    P.S. BoostMacroPerformance is a method that I use to set certain settings of the application (ScreenUpdating, EnableEvents, Calculation and DisplayAlerts) to boost the speed of macro to an extent.

    Only thing that am not able to get the property - "Last Saved By" of the file and any alternate ways to boost up the speed by avoiding loop if we can..

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Files within Multiple SubFolders and SubFolders Within It

    There's any number of ways of doing it, including hiding the Command window and these are a lot faster than recursive looping.

    But explain the 'Last Saved By' property. As far as I know that's not one of the properties saved with a file. Where does it come from?

  5. #5
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Files within Multiple SubFolders and SubFolders Within It

    It is buddy. Actually, it seems that it comes with Windows 7 as I haven't seen this property in Windows XP or before. Its an extended property under Origin section. Can't find a way to get to it..

    http://s23.postimg.org/j5rxjftu3/Last_Saved_By.jpg
    Last edited by codeslizer; 09-16-2013 at 07:20 AM.

  6. #6
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Files within Multiple SubFolders and SubFolders Within It

    Hey Guys,

    I made a little research, and have found that the property actually belongs to BuiltinDocumentProperties of the workbook and can be made in use when file is open. Any ways to call use this property without opening the file..? Below code works and gets me the detail

    Please Login or Register  to view this content.
    Last edited by codeslizer; 09-16-2013 at 07:56 AM.

  7. #7
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Files within Multiple SubFolders and SubFolders Within It

    Alright, I've got the solution to my issue. It involves usage of an extra DLL called "DSOFile" which I believe will be working on only with Office version - 2007 onwards. Am not sure about whether if it works for 2003 or before.

    Please Login or Register  to view this content.
    Here is the link from where I got my solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. import multiple html files from multiple and subfolders
    By wali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2011, 04:33 PM
  3. A Way to Query,(x).Xls files in (x)subfolders
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 52
    Last Post: 08-06-2011, 04:17 AM
  4. Open all files in subfolders
    By linglc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2006, 05:40 AM
  5. [SOLVED] copy subfolders, replace text in files and save files in copied subfolders
    By pieros in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-01-2005, 09:05 AM

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