Guten Morgen zusammen,
ich habe in meiner Userform eine ListBox und ein Image. Wird ein Eintrag aus der ListBox angeklickt, füllt sich das Image automatisch anhand des jeweiligen Dateipfades.
Mit einem Bild habe ich keine Probleme, beim zweiten bekomme ich "Invalid Picture". Meine Suche hat ergeben, dass das Problem wohl die Farbtiefe ist (einmal 24 -> geht, einmal 32 -> geht nicht). An einer anderen Stelle kann man die Bilder hinzufügen, sodass ich nicht einfach meine Auswahl auf 24 Bit beschränken kann. Habt ihr eine Idee?
Private Sub ListBox1_Change()
lastR = Worksheets("Partner").Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastR
If Worksheets("Partner").Range("A" + CStr(i)).Value = ListBox1.Value Then
If Dir(ThisWorkbook.Path + "\Logos\" + Worksheets("Partner").Range("B" + CStr(i)).Value + ".jpg") <> "" Then
Image1.Visible = True
'MsgBox ThisWorkbook.Path + "\Logos\" + Worksheets("Partner").Range("B" + CStr(i)).Value + ".jpg"
Image1.Picture = LoadPicture(ThisWorkbook.Path + "\Logos\" + Worksheets("Partner").Range("B" + CStr(i)).Value + ".jpg")
Else:
Image1.Visible = False
End If
End If
Next i
End Sub
|