C
Conan Kelly
Hello all,
I have a folder on a network share that has the following files in it sorted by Name:
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
053120062DD.txt
063020062DD.txt
073120062DD.txt
RE follow up.htm
Notice the 3 text files at the bottom. They are out of order. They appear to start with a zero rather than the letter O.
When I sort by Type, this is the order they are in:
RE follow up.htm
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
053120062DD.txt
063020062DD.txt
073120062DD.txt
the 3 bottom text files are still out of order.
When I run the following 2 samples of code in Word and Excel, the results are the same:
'MS Word
Sub TESTING()
Dim fso As New FileSystemObject
Dim fsoFolder As Folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder("X:\FolderName\SubFolderName")
For Each fsoFile In fsoFolder.Files
Selection.TypeText fsoFile.Name
Selection.TypeParagraph
Next fsoFile
End Sub
'MS Excel
Sub TESTING()
Dim fso As New FileSystemObject
Dim fsoFolder As Folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder("X:\FolderName\SubFolderName")
For Each fsoFile In fsoFolder.Files
ActiveCell = fsoFile.Name
Cells(ActiveCell.Row + 1, ActiveCell.Column).Select
Next fsoFile
End Sub
Here is the results:
053120062DD.txt
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
063020062DD.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
073120062DD.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
RE follow up.htm
I even went as far as doing this in Excel:
Cell A1:
053120062DD.txt '<---Copied the file name into it from Windows Explorer
Cell B1:
=CODE(A1)
Cell A2:
=RIGHT(A1,LEN(A1)-1)
Cell B2:
=CODE(A2)
Now I selected the range A2:B2 and filled that down until I ran out of letters in the file name. The codes for the first character
in the file name and the 2 zeros in the year were all 48. After that I copied one of the file names of the files that are in order
to cell A1 and got the same results: the first character and the 2 zero's have the same code.
Anyone have any idea as to why Windows Explorer is sorting these files this way?
Thanks for any help anyone can provide,
Conan Kelly
I have a folder on a network share that has the following files in it sorted by Name:
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
053120062DD.txt
063020062DD.txt
073120062DD.txt
RE follow up.htm
Notice the 3 text files at the bottom. They are out of order. They appear to start with a zero rather than the letter O.
When I sort by Type, this is the order they are in:
RE follow up.htm
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
053120062DD.txt
063020062DD.txt
073120062DD.txt
the 3 bottom text files are still out of order.
When I run the following 2 samples of code in Word and Excel, the results are the same:
'MS Word
Sub TESTING()
Dim fso As New FileSystemObject
Dim fsoFolder As Folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder("X:\FolderName\SubFolderName")
For Each fsoFile In fsoFolder.Files
Selection.TypeText fsoFile.Name
Selection.TypeParagraph
Next fsoFile
End Sub
'MS Excel
Sub TESTING()
Dim fso As New FileSystemObject
Dim fsoFolder As Folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder("X:\FolderName\SubFolderName")
For Each fsoFile In fsoFolder.Files
ActiveCell = fsoFile.Name
Cells(ActiveCell.Row + 1, ActiveCell.Column).Select
Next fsoFile
End Sub
Here is the results:
053120062DD.txt
05312006DD.txt
05312006NIBDD.txt
05312006NIBSA.txt
05312006SA.txt
063020062DD.txt
06302006DD.txt
06302006NIBDD.txt
06302006NIBSA.txt
06302006SA.txt
073120062DD.txt
07312006DD.txt
07312006NIBDD.txt
07312006NIBSA.txt
07312006SA.txt
RE follow up.htm
I even went as far as doing this in Excel:
Cell A1:
053120062DD.txt '<---Copied the file name into it from Windows Explorer
Cell B1:
=CODE(A1)
Cell A2:
=RIGHT(A1,LEN(A1)-1)
Cell B2:
=CODE(A2)
Now I selected the range A2:B2 and filled that down until I ran out of letters in the file name. The codes for the first character
in the file name and the 2 zeros in the year were all 48. After that I copied one of the file names of the files that are in order
to cell A1 and got the same results: the first character and the 2 zero's have the same code.
Anyone have any idea as to why Windows Explorer is sorting these files this way?
Thanks for any help anyone can provide,
Conan Kelly