I don't think it is anything to do with the selection order, I think it is
to do with the OS, and where it thinks they are. When you see a list of
files, it is always ordered in some way, but that has nothing to do with the
way that it is stored.

Signature
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
> Can someone explain to me why when the following code executes, the
> filename shown in the message box for the first iteration is the last
[quoted text clipped - 22 lines]
>
> Garry
gw.boswell@gmail.com - 15 Jan 2007 17:04 GMT
OK, I can accept that. However, I need to address the file names in
order. Any suggestions as to how to do that?
> I don't think it is anything to do with the selection order, I think it is
> to do with the OS, and where it thinks they are. When you see a list of
[quoted text clipped - 34 lines]
> >
> > Garry
Bob Phillips - 15 Jan 2007 17:37 GMT
You could sort the array
Dim FileToOpen As Variant
Dim counter As Long
FileToOpen = Application.GetOpenFilename("TableFiles (*.prn), *.prn", , _
"Name of Files to Use", , True)
Call ShellSort(FileToOpen)
counter = 1
Do While counter <= UBound(FileToOpen)
MsgBox FileToOpen(counter)
counter = counter + 1
Loop
End Sub
Public Sub ShellSort(ByRef aryToSort)
Dim i As Long, j As Long
Dim iLow As Long, iHigh As Long
Dim tmp As Variant
iLow = LBound(aryToSort)
iHigh = UBound(aryToSort)
j = (iHigh - iLow + 1) \ 2
Do While j > 0
For i = iLow To iHigh - j
If aryToSort(i) > aryToSort(i + j) Then
tmp = aryToSort(i)
aryToSort(i) = aryToSort(i + j)
aryToSort(i + j) = tmp
End If
Next i
For i = iHigh - j To iLow Step -1
If aryToSort(i) > aryToSort(i + j) Then
tmp = aryToSort(i)
aryToSort(i) = aryToSort(i + j)
aryToSort(i + j) = tmp
End If
Next i
j = j \ 2
Loop
End Sub

Signature
---
HTH
Bob
(change the xxxx to gmail if mailing direct)
> OK, I can accept that. However, I need to address the file names in
> order. Any suggestions as to how to do that?
[quoted text clipped - 39 lines]
>> >
>> > Garry