I haven't used ImageList control before and am a bit lost!
I have added the ImageList control to my userform and now need to add all the images in a folder to that control.
I have tried a variety of methods after doing a google search but none worked.
Any help greatly appreciated.
Hi there,
First, which version of Excel are you using?
What do you mean with "ALL THE IMAGES"? A picklist?
Can you attach a sample of your file?
I am using windows 11 with Office 365
By "all the images" I meant all the files, which are .jpg files, in a folder which contains only the required .jpg files.
Since posting this I have got it to work with:
Option Explicit
Dim optBtns(1 To 6) As New clsOptBtns
Dim Res, sQty$, sCat$, b As Boolean
Private Sub UserForm_Initialize()
Dim x, i&, ii&, li As ListItem, ctl As MSForms.Control, b As Boolean
Dim file, sPath$
x = [tblDice]: b = True
sPath = ThisWorkbook.Path & "PaintColours"
For Each ctl In Me.Controls
If TypeName(ctl) = "OptionButton" Then
i = i + 1: Set optBtns(i).btnOpt = ctl
End If
Next
frSubmit.Visible = 0
With Me
.StartUpPosition = 0
.Left = Application.Left
.Top = Application.Left
End With
file = Dir(sPath)
With Me.imlPaintColor
.ListImages.Clear
While (file <> "")
.ListImages.Add , file, LoadPicture(sPath & file)
file = Dir
Wend
End With
End Sub
I was missing the LoadPicture previously and just had
.ListImages.Add , file, sPath & file
Needed to reply to the lastest post in order to moderate it. Unfortunately, I'm in no position to help you with VBA 🙂
Thanks Riny.
As I said in my previous reply I managed to resolve the issue.
You see, I didn't even understand you solved the problem 🙂