Hello Colin Smit,
Here is the revised code for the UserForm. The attached workbook has all the changes included.
Private Sub cmdbutton_close_Click()
Unload Me
End Sub
Private Sub cmdbutton_submit_Click()
Dim Filepath As String
Dim nList As Long
nList = ComboBox1.ListIndex
If nList > -1 Then
Filepath = ComboBox1.List(nList, 1)
Image1.Picture = LoadPicture(Filepath)
End If
End Sub
Private Sub UserForm_Initialize()
Dim Descending As Boolean
Dim oFiles As Object
Dim oFile As Object
Dim Folder As Variant
Dim List As Variant
Dim j As Long
Dim n As Long
Dim Sorted As Boolean
Dim Temp As Variant
Folder = "C:\Users\Owner\Documents"
With CreateObject("Shell.Application")
Set oFiles = .Namespace(Folder).Items
oFiles.Filter 64, "*.jpg"
ReDim List(1 To oFiles.Count, 1 To 2)
For Each oFile In oFiles
n = n + 1
List(n, 1) = oFile.Name
List(n, 2) = oFile.Path
Next oFile
End With
Do
Sorted = True
For j = 1 To n - 1
If Descending Xor List(j, 1) > List(j + 1, 1) Then
Temp = List(j + 1, 1)
List(j + 1, 1) = List(j, 1)
List(j, 1) = Temp
Temp = List(j + 1, 2)
List(j + 1, 2) = List(j, 2)
List(j, 2) = Temp
Sorted = False
End If
Next j
n = n - 1
Loop Until Sorted Or n < 1
ComboBox1.List = List
End Sub
Bookmarks