Load image into image box advice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Afternoon,

Ive got a userform which is working well but struggling to load an image when text boxes are filled with data from combobox selection.
Ive used a code taken from another page but need help please on correctly adding the path to where the images are stored.
This is the path for where the images are.
DESKTOP,REMOTES,LOCK PICKING IMAGES

Now when i make a selection from the combobox not only does the text boxes get entered with the correct data but also an image.

I have supplied the code in use below.

Code:
Private Sub ComboBox1_DropButt*******()Dim i As Long, LastRow As Long
LastRow = Sheets("INFO").Range("BC" & Rows.Count).End(xlUp).Row
If Me.ComboBox1.ListCount = 0 Then
For i = 2 To LastRow
Me.ComboBox1.AddItem Sheets("INFO").Cells(i, "BC").Value
Next i
End If
End Sub
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets("INFO").Range("BC" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("INFO").Cells(i, "BC").Value = (Me.ComboBox1) Or _
Sheets("INFO").Cells(i, "BC").Value = Val(Me.ComboBox1) Then
Me.TextBox1 = Sheets("INFO").Cells(i, "BE").Value
Me.TextBox2 = Sheets("INFO").Cells(i, "BG").Value
Me.TextBox3 = Sheets("INFO").Cells(i, "BI").Value
Me.TextBox4 = Sheets("INFO").Cells(i, "BK").Value
Me.TextBox5 = Sheets("INFO").Cells(i, "BM").Value
Me.TextBox6 = Sheets("INFO").Cells(i, "BO").Value
Me.TextBox7 = Sheets("INFO").Cells(i, "BS").Value
Me.TextBox8 = Sheets("INFO").Cells(i, "BQ").Value
Me.TextBox9 = Sheets("INFO").Cells(i, "BU").Value
End If
Next
End Sub
Private Sub KeyType_Change()
If (Me.TextBox1.Value) = "" Then
   Me.Image1.Picture = LoadPicture(ThisWorkbook.Path & "\dr-logo.jpg")
Else
  Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & HondaPartNumber.Value & ".jpg")
End If
End Sub

Many thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
HondaPartNumber.Value doesn't seem to have any value assigned to it. If it does, the file location has to be a string. So, maybe...
Code:
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & CSTR(HondaPartNumber.Value) & ".jpg")
HTH. Dave
 
Upvote 0
Many thanks for the reply.
It was an oversight that I forgot to edit.

Basically when you open the userform a default image is shown.
Then when you make a selection from the combo box all the cells are filled with my relevant info.
This has been completed but I need also the image to be placed into the image box.
I have images ready that match the text in the combobox.
My problem is the correct code.
My path to the images is mentioned above so I’m stuck with the correct code so the image is loaded.
Example.
If I select say HU64 from the combobox not only does its relevant info get places into the text boxes but I also need the image HU64 put into the image box.
This is the same if I select HU92 or HU101 etc.

Thanks for your time.
 
Upvote 0
Not sure why U have the code in a keytype change....shouldn't it be in the combobox change? I really don't understand your reply to my post? It's simply a matter of getting the file name right and then loading it to the image control. Dave
 
Upvote 0
To be honest I’m stumped.
I need to just start from the beginning.
So at present like this.
If Textbox10 is empty then load my default photo. “ I will then try and go from there after but let’s do this first please”
My default photo is dr-logo.jpg
It’s location is as follows.
C
Desktop
Remotes
Lock picking images.
Space in between lock picking images, I tried % but no joy.
 
Upvote 0
Code:
If ME.Textbox10.text = VBNullstring then
Image1.Picture = LoadPicture("C:\Desktop\Remotes\Lock_picking_images\dr-logo.jpg")
End if
HTH. Dave
 
Upvote 0
Merry Christmas.
That didnt work for me im sorry.
I will now leave this and think of something different.

thanks again
 
Upvote 0
No _ are required between text,so its like this.

Code:
[COLOR=#333333]Image1.Picture = LoadPicture("C:\Desktop\Remotes\Lock picking images\dr-logo.jpg")[/COLOR]
 
Upvote 0
Are you sure that's the right path to the file ?

Open Windows Explorer, click on disk(C) and navigate to the file from there to be sure.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,753
Messages
6,180,748
Members
452,996
Latest member
nelsonsix66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top