Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
Hi,
I have a macro where I do the following: 1) Search for all files in a directory: Set fs = Application.FileSearch With fs .LookIn = dirtosearch .SearchSubFolders = True .Filename = "*.*" .Execute If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) 0 Then Max = .FoundFiles.Count for i = 1 to max list(i) = .foundfiles(i) next i ******at this point I pause the code And look at the list array using the watch window, expecting that the entries are in alphabetical order by the filename. What I find is it is "almost" in alphabetical order. I found, for example, the filename for 1213="Mat...", 1214="Man...", 1215="Mat..."! Help! For my code I need the files to be alphabetized. What am I doing wrong? Suggestions? Thanks everyone, Phil |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
You're probably not doing anything wrong. With XL2000 and XL2002, I've found
FileSearch to be "flaky" at best, sometimes returning a count of 0 when there ARE matching files. Bill Manville has, in the past, posted a recursive Directory routine. I don't know if it alphabetizes the files or not. Search Google for it. If it doesn't sort them, search also for a QuickSort routine. On 22 Feb 2005 19:52:13 -0800, "General" wrote: Hi, I have a macro where I do the following: 1) Search for all files in a directory: Set fs = Application.FileSearch With fs .LookIn = dirtosearch .SearchSubFolders = True .Filename = "*.*" .Execute If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) 0 Then Max = .FoundFiles.Count for i = 1 to max list(i) = .foundfiles(i) next i ******at this point I pause the code And look at the list array using the watch window, expecting that the entries are in alphabetical order by the filename. What I find is it is "almost" in alphabetical order. I found, for example, the filename for 1213="Mat...", 1214="Man...", 1215="Mat..."! Help! For my code I need the files to be alphabetized. What am I doing wrong? Suggestions? Thanks everyone, Phil |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
ahh crud....that will make things a lot more difficult. Anyone have any
workarounds? Or, any ways to easily alphabetically sort an array? I can make a 2-D array that has the filename only in one column and sort on that - I just don't know how to alphabetize an array. Any help is appreciated. phil |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
You can use an ADO recordset as a sortable container for file info
http://www.4guysfromrolla.com/webtech/011401-1.shtml Tim. "General" wrote in message oups.com... ahh crud....that will make things a lot more difficult. Anyone have any workarounds? Or, any ways to easily alphabetically sort an array? I can make a 2-D array that has the filename only in one column and sort on that - I just don't know how to alphabetize an array. Any help is appreciated. phil |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
If you look at the thread API to find file of 21 Feb 05 in this group there
is a routine that I think does get the path names in alphabetical order. There are plenty of routines around to sort a 1-D or 2-D array. If you can't find any I am sure somebody can post one here. RBS "General" wrote in message oups.com... ahh crud....that will make things a lot more difficult. Anyone have any workarounds? Or, any ways to easily alphabetically sort an array? I can make a 2-D array that has the filename only in one column and sort on that - I just don't know how to alphabetize an array. Any help is appreciated. phil |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
Thanks everyone.
I ended up parsing the full filename, so in the second column of the array, I had just the filename. Then I dumped the array into Excel and sorted by the filename, and then rewrote everything back into the array. It only took about 1 minute to do that portion, start to finish, for 35,000 files. It's REALLY annoying though that the filesearch doesn't really alphabetize. That's a pretty important detail to screw up - esp since there's a specific option to sort by filename...Maybe MS will give me my $$ back? :) Thanks for everyones help. Phil |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Filesearch returning files not in alphabetical order?
For me it screws up even worse: the file count is returned as 0, when it isn't
0. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
order of opening files with sumproduct returning #REF! | Excel Worksheet Functions | |||
How do you view files in an alphabetical ORDER ? | Excel Discussion (Misc queries) | |||
Alphabetical order of files | Excel Discussion (Misc queries) | |||
why are my files out of alphabetical order? | Excel Discussion (Misc queries) | |||
FileSearch macro returning incorrect docs? | Excel Programming |