Article View: microsoft.public.excel.misc
Article #3920Re: Files in Directory Tree
From: "Jim Mack"
Date: Thu, 05 Nov 1998 00:00
Date: Thu, 05 Nov 1998 00:00
41 lines
1657 bytes
1657 bytes
You can do this in pure VB code, but it's a little tricky because the Dir() function can't be used recursively. So you use Dir() to create an array of top level dirs, and then search within those for more dirs, etc, until you have a complete tree. Now you can use that array to search for files, again using Dir(). There are several API examples in the various VB pages on the web... try www.mvps.org/vbnet for starters. Since the API can be used recursively, it's more straightforward code, and faster too. If you'll accept a commercial solution, take a look at my company's Stamina library. It has several functions to read directory contents (among 370+ routines written in ASM for VB and VBA). The most relevant to your question is probably DxDirTree, used with DxPathFromTree. It returns an array of a UDT containing complete information about all the files and dirs in a tree, starting at any point you specify. Then there's DxSearchVolume, which returns the full path name to all files on a drive (or any subtree) which match a passed spec. -- Jim Mack MicroDexterity, Inc http://www.microdexterity.com Sales: 888-891-0700 sales@mdxi.com Support: +1 734-453-5872 support@mdxi.com Steven Reid wrote in message <#FFYc5LC#GA.187@uppssnewspub04.moswest.msn.net>... >Hi Everybody, > >Could someone tell me a good way in VBA of getting a list of files that >exist >within a directory tree within Excel 95. > >This could be from one to "lots" of sub directories and multiple levels >deep. > >I am trying to get the details of all files below a certain directory and >then compare that to a master list of files.
Message-ID:
<71sdrc$np8$1@denws02.mw.mediaone.net>
Path:
rocksolid-us.pugleaf.net!archive.newsdeef.eu!mbox2nntp-microsoft.public.excel.links.mbox.zip!not-for-mail
References:
<#FFYc5LC#GA.187@uppssnewspub04.moswest.msn.net>