I have a VB6 routine requiring a tweak, the following code loads images into a listbox control:
Code: Select all
Private Sub cmdImportAF_Click()
Const MYCOMPUTER As String = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
On Error GoTo cError
Dim i As Integer
Dim myFiles() As String
Dim myPath As String
ClearList
With cmnDialog1
.MaxFileSize = 32000 'this will max out the buffer for the filenames array for large selections. *NEW*
.CancelError = False 'if cancel is pressed, the code jumps to cError because of the On Error statement above
.Filter = "JPG Files (*.jpg;*.jpeg)|*.jpg;*.jpeg"
'Text Files (*.txt)|*.txt|Graphic Files (*.bmp;*.gif;*.jpg)|*.bmp;*.gif;*.jpg|All Files (*.*)|*.*
.FilterIndex = 2
.FileName = ""
.InitDir = MYCOMPUTER
.Flags = CD_FLAGS 'this is where we tell it to use multiselect
.ShowOpen
myFiles = Split(.FileName, vbNullChar) 'the Filename returned is delimeted by a null character because we selected the cdlOFNLongNames flag
Select Case UBound(myFiles)
Case 0 'if only one was selected we are done
lstImages.AddItem myFiles(0)
Case Is > 0 'if more than one, we need to loop through it and append the root directory
For i = 1 To UBound(myFiles)
myPath = myFiles(0) & IIf(Right(myFiles(0), 1) <> "\", "\", "") & myFiles(i)
lstImages.AddItem myPath
Next i
End Select
Me.txtFileCount.Text = "Total Images In Folder" & " " & Me.lstImages.ListCount
End With
Exit Sub
cError:
Beep
MsgBox Err.Description '*NEW*
End Sub
So the current code will see for example:
L:\mmpdf\consolefiles\12345
The change in the code would need to see:
L:\mmpdf\consolefiles\12345\_IMAGES
Obviously that is if the _IMAGES folder exists which it doesn't in all occasions.
Would anyone mind tweaking the routine for this to happen/
Many Thanks.