Results 1 to 10 of 40

Thread: Notes tests. Excel VBA Folder File Search

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    _................................................. .........

    Rudi's code from Rem 5R)

    This works differently in a way I have never seen before. There is no need to call a "recursion Routine"

    Initially The main Folder is "put" into a "Queue" ( at the " back " of it )
    https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
    https://msdn.microsoft.com/de-de/lib...(v=vs.90).aspx
    ( I expect in the "Queue" is just holding the Pointer to the actual Folder Object
    The code the does a similar For Next as in my Code. One major difference is that the first thing it does is at each Folder is to go through every Sub Folder therein and "Put" it at the "back" of the queue. It takes the current folder being "looked" at "out" of the Queue from the "front".

    It effectively then "stacks up all" the Folders in the next level down. Eventually after it goes through every Folder in the current level it will reach the point where it starts on the next level. So effectively it does not go "back and forth" like mine does. Rather it has "looking up" or "back from the front" first all the first level Folders, then all the next level Folders , then all the next, and so on.
    If you look at the difference in the output that I get from mine and Rudi's code, you will soon see the corresponding difference.

    Again the tricky bit for me was to get a Variable to indicate the "level" or "column to the left".

    What I do in this case is count every time a Sub Folder is put in the back of the Queue.
    NxtLvlCnt
    This will finally give an indication of the Number of Sub folders at the next level.
    I have second count variable
    CurrentLvlCnt
    Which is originally set to the last level count ( set initially to one for the original main folder ), which is successively decreased each time a Folder is "taken out" of the queue. When it reaches zero it is an indication that we have reached the next series of Next level Sub Folders. When that occurs it is given the value of the next level Count, and the next level Cont is then reset to Zero.

    _................................................. .......

    For both code I finally added a bit of Error handling. I did this as when I tested with many real files , I often had an error if , for example the "doing stuff" involved opening a file. If this happens you are told what error occurred and to which file, then you go on to the next. ( I assume that errors do not occur in the original code that just Prints out the "explorer type" Listing. If it did I expect the output could go a bit out if step !! ) )

    _...............................................

    So I give here some typical output from a run of both codes. To make it a bit easier I include the example set of Folders I used. ( I hope they all come up. By me only a few Folders come up, although the are "indicted as all there " ? ? )
    https://app.box.com/s/onj6ntvwkxbo1088x7e0tca2gst45hnq
    ( Edit : Here is another Folder to try https://app.box.com/s/9e6xnb65fijjhl7bk0q6gzzriihkzibw )


    words I have a main
    EileensFldr

    That has three sub folders in it. Therein are files and further sub Folders and files etc…. as seen in the listing the Code gives.

    Initially the code is set to run from a file in the same directory as folder EileensFldr
    Last edited by DocAElstein; 01-23-2020 at 02:44 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Tests and Notes on Range Referrencing
    By DocAElstein in forum Test Area
    Replies: 70
    Last Post: 02-20-2024, 01:54 AM
  2. Tests and Notes for EMail Threads
    By DocAElstein in forum Test Area
    Replies: 29
    Last Post: 11-15-2022, 04:39 PM
  3. Replies: 1
    Last Post: 02-14-2013, 12:09 PM
  4. List File name in folder to excel with images
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 01-15-2013, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •