ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change image in UserForm (https://www.excelbanter.com/excel-programming/353763-change-image-userform.html)

Joseph[_58_]

Change image in UserForm
 
I want to create a userform with a listbox that has 4 columns, one
column is Customer#. Each item in the list will have a related picture
of the same name (i.e. Customer# 01234 = X:\Pictures\01234.jpg) stored
in a folder on my computer.

Is it possible to have the Image control on the userform updated 'when
the item in the list is selected' rather than having to click on a
command button, so that each time you would select an item in the list,
the image on the userform would change?

Thanks,
Joe


Tom Ogilvy

Change image in UserForm
 
Private Sub Listbox1_Click()
if listbox1.ListIndex < -1 then
Image1.Picuture = loadPicture( _
"X:\Pictures\" & Listbo1.Value & ".jpg")
end if
End Sub

Depends on what the value of Listbox1 is. Here, I assume it is the name of
the picture (Customer#). Set the customer# column as the BoundColumn for
the listbox.

--
Regards,
Tom Ogilvy


"Joseph" wrote in message
ups.com...
I want to create a userform with a listbox that has 4 columns, one
column is Customer#. Each item in the list will have a related picture
of the same name (i.e. Customer# 01234 = X:\Pictures\01234.jpg) stored
in a folder on my computer.

Is it possible to have the Image control on the userform updated 'when
the item in the list is selected' rather than having to click on a
command button, so that each time you would select an item in the list,
the image on the userform would change?

Thanks,
Joe





All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com