Forum

Notifications
Clear all

Loading images from a folder into user form ImageList control

6 Posts
3 Users
0 Reactions
207 Views
(@kjbox)
Posts: 69
Trusted Member
Topic starter
 

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.

 
Posted : 11/10/2024 2:12 am
(@keebellah)
Posts: 373
Reputable Member
 

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?

 
Posted : 12/10/2024 2:30 am
(@kjbox)
Posts: 69
Trusted Member
Topic starter
 

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

 
Posted : 12/10/2024 3:08 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

Needed to reply to the lastest post in order to moderate it. Unfortunately, I'm in no position to help you with VBA 🙂

 
Posted : 13/10/2024 9:41 am
(@kjbox)
Posts: 69
Trusted Member
Topic starter
 

Thanks Riny.

As I said in my previous reply I managed to resolve the issue.

 
Posted : 14/10/2024 12:32 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

You see, I didn't even understand you solved the problem 🙂

 
Posted : 14/10/2024 2:22 am
Share: