Visual Basic for Applications/Recursive File Listing of Folders

Summary

 * Recursive listings are tricky, and it is found to be difficult without module or public declarations of some sort.  This version although a bit clumsy will perform as expected for files that can be accessed.
 * A public variable is used as a counter to keep track, between iterations, of the numbers of files found, since Microsoft advises us that static variables are not usually used with recursion.  The VBA code is not specific for any particular Office application, so would work in say MS Excel or MS Word etc.
 * The user might need to introduce more filtering; for example, to exclude certain file types, or to avoid those of zero size.  A comment in the code listing shows where such a code function could be added to the existing condition.
 * Because the array is public, it can be accessed from any other module for its further processing or output. Copy the code entirely into a code module, and modify the folder and recursion condition to your own values.
 * My Documents versus Documents. There are four virtual folders in Libraries, My Documents, My Music, My Pictures, and My Videos. When the Windows Explorer's Folder Options forbid the display of hidden files, folders, and drives, the correct locations are returned by various folder selection dialogs, namely Documents, Music, Pictures, and Videos. When hidden folders are permitted, then dialogs and listings will attempt to make use of these virtual paths. Access violations will result. To avoid undue problems, check that your folder options are set not to show hidden files or folders.  This procedure avoids these folders altogether, but access violations can be avoided, provided that hidden files are allowed to stay hidden.