RE: Most efficient way to loop through a folder and find all the XLS f



I think dir is the easiest way


Folder = "c:\temp\"
FName = dir(Folder & "*.xls")
Do while FName <> ""
set bk = workbooks.open(filename:=FName)
'enter your code here

bk.close savechanges:=False
FName = dir()
loop




"Barb Reinhardt" wrote:

I've done this a number of ways, but am wondering what the most efficient way
is to loop through a folder. I've used DIR and File Scripting Objects.
Which is the best way?

Thanks,
Barb Reinhardt
.



Relevant Pages

  • Re: reading file list, writing to text file
    ... fname %check it is reading all files ... The reason your loop is overwriting the previous text file is that you ... you should not open the file for reading multiple times - that is ... count = fprintf(fid, myfname); ...
    (comp.soft-sys.matlab)
  • Re: Variable value in while loop
    ... > declare -i size ... > while read size fname; ... > Inside a while loop all variable values are echoed OK, ... > because of the pipe agter awk. ...
    (comp.unix.shell)
  • Re: Problem using FileUtils to sort JPEG files
    ... of the for loop and only doing it once, ... Dir.glob.each do |fname| ... new scope. ... FileUtils.move(fname, "#{workdir}/#{filetype}") #workdir is ...
    (comp.lang.ruby)
  • Re: mv xrags and cp
    ... If you want do it with a loop use a while loop: ... find olddir -name '*.jpg | while read fname; ... do_something_with_file $fname ... breaks on any white space whatsoever. ...
    (Ubuntu)
  • Re: Print to new file for each results
    ... On 08/29/2006 06:32 PM, Ron McKeever wrote: ... My goal instead of having all the data in one big file is to loop this and create a file for each result. ... $fname = catfile; ...
    (perl.beginners)