M
Mike Archer
Hello -
I have created a File picker for selecting pictures and assigning the picked
files to semi-colon seperated string variables. It works fine, except that
the files are displayed in descending order. They must be shown in ascending
order for my purposes. I can't figure out what is causing this. When the
filedialog is running, you can right click on it and select "arrange by name"
to toggle back and forth from ascending to descending. I can't find the VBA
representation of "arrange by". Please look over my code and show me where I
am going wrong... or suggest a work around:
Dim fd As FileDialog, lstStr As String, loopCtr As Integer
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.FilterIndex
.Filters.Clear
.InitialView = msoFileDialogViewPreview
.InitialFileName = FolderPath
.Filters.Add IMAGEFILES, IMAGETYPES
.AllowMultiSelect = True
If .Show = True Then
loopCtr = 0
lstStr = FileNamesPaths.Value
ShortStr = ShortFileName.Value
For Each vrtSelectedItem In .SelectedItems
FilesArray = vrtSelectedItem
loopCtr = loopCtr + 1
lstFilesSelected.AddItem vrtSelectedItem
lstStr = lstStr & vrtSelectedItem & ";"
If Me.CheckBox1.Value = True Then
ShortStr = ShortStr & Replace(currentTitle, " ", "_") & "_" &
loopCtr & "." & FunctionGetFileExt(vrtSelectedItem) & ";"
Else
ShortStr = ShortStr & FunctionGetFileName(vrtSelectedItem) & ";"
End If
Next vrtSelectedItem
FileNamesPaths.Value = lstStr
ShortFileName.Value = ShortStr
Else
'The user pressed Cancel.
Exit Sub
End If
End With
I have created a File picker for selecting pictures and assigning the picked
files to semi-colon seperated string variables. It works fine, except that
the files are displayed in descending order. They must be shown in ascending
order for my purposes. I can't figure out what is causing this. When the
filedialog is running, you can right click on it and select "arrange by name"
to toggle back and forth from ascending to descending. I can't find the VBA
representation of "arrange by". Please look over my code and show me where I
am going wrong... or suggest a work around:
Dim fd As FileDialog, lstStr As String, loopCtr As Integer
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.FilterIndex
.Filters.Clear
.InitialView = msoFileDialogViewPreview
.InitialFileName = FolderPath
.Filters.Add IMAGEFILES, IMAGETYPES
.AllowMultiSelect = True
If .Show = True Then
loopCtr = 0
lstStr = FileNamesPaths.Value
ShortStr = ShortFileName.Value
For Each vrtSelectedItem In .SelectedItems
FilesArray = vrtSelectedItem
loopCtr = loopCtr + 1
lstFilesSelected.AddItem vrtSelectedItem
lstStr = lstStr & vrtSelectedItem & ";"
If Me.CheckBox1.Value = True Then
ShortStr = ShortStr & Replace(currentTitle, " ", "_") & "_" &
loopCtr & "." & FunctionGetFileExt(vrtSelectedItem) & ";"
Else
ShortStr = ShortStr & FunctionGetFileName(vrtSelectedItem) & ";"
End If
Next vrtSelectedItem
FileNamesPaths.Value = lstStr
ShortFileName.Value = ShortStr
Else
'The user pressed Cancel.
Exit Sub
End If
End With