Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
order of opening files with sumproduct returning #REF! sharon p Excel Worksheet Functions 2 September 15th 09 05:29 PM
How do you view files in an alphabetical ORDER ? John Excel Discussion (Misc queries) 1 July 11th 08 05:54 PM
Alphabetical order of files LD Excel Discussion (Misc queries) 1 June 23rd 06 10:22 AM
why are my files out of alphabetical order? kwardja Excel Discussion (Misc queries) 2 June 19th 06 02:32 PM
FileSearch macro returning incorrect docs? Ed[_9_] Excel Programming 2 December 10th 03 05:48 PM


All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"