View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default GetOpenFilename xl2000 vs xl2002

Hi Greg

I am on Excel 2002 SP2.

Using your test (changed jpeg to xls extension) I find the following. If
I use the shift key to select 1 file the last file selected is indeed
the first element of the array. However, the other files are listed in
reverse order to how they appear in the folder i.e if my files in the
folder are listed as follows:
ABC.xls
GEF.xls
XYZ.xls
and I select ABC, hold down shift and then select XYZ the message boxes
appear in this order: XYZ.xls, GEF.xls, ABC.xls.

Alternately if I select XYZ.xls, hold shift and then select ABC.xls the
order in the array is ABC.xls, GEF.xls, XYZ.xls.

Hope this helps
Rowan

Greg Wilson wrote:
Using GetOpenFilename with MultiSelect set to True, when you select files
using the <Shift key they become highlighted and the last in the selection
also has a dashed border. In xl2002, the name of the file with the dashed
border apparently becomes the first element in the array even if it is the
last in the selection. The remainder are listed according to their order in
the folder. This is a departure from xl2000 and is screwing up a project of
mine.

I don't have xl2002 at home and can't double-check it. The above conclusion
was arrived at on Friday using a computer at work that had a program of mine
that was screwing up. The code I used to check it follows. Hoping somehow I
am confused or someone has a simple fix for this. Otherwise I have to create
a clunky patch.

Best regards,
Greg

Sub Test()
Dim FNs As Variant
Dim i As Long
With Application
FNs = .GetOpenFilename("Picture files(*.jpg), *.jpg", _
MultiSelect:=True)
End With
If TypeName(FNs) = "Boolean" Then Exit Sub
For i = LBound(FNs) To UBound(FNs)
MsgBox FNs(i)
Next
End Sub