Besteht eine Möglichkeit, jpg-Bildern über Listbox-Userform anzuzeigen? Je Listbox-Eintrag entspricht ein Bild, das neben der Listbox angezeigt wird. Bitte um Hilfe!!
lg Marco
Private Sub ListBox1_Click()
Image1.Picture = LoadPicture(ListBox1.Value)
End Sub
Private Sub UserForm_Activate()
Dim x, b
For x = 0 To 2
b = Range("A" & x + 1)
ListBox1.AddItem b
Next x
End Sub
Sub BilderKommentar()
Dim x%, oComm As Comment, sPfad$, iEnde%
iEnde = ActiveCell.SpecialCells(xlLastCell).Row
For x = 0 To iEnde - 1
Range("A" & x + 1).ClearComments
sPfad = Range("A" & x + 1)
' Kommentar einfügen
Set oComm = ActiveSheet.Range("A" & x + 1).AddComment
With oComm
.Shape.Fill.UserPicture sPfad
.Shape.Height = 150 'oder wie groß auch immer...
.Shape.Width = .Shape.Height * 0.75
End With
Next x
End Sub
Private Sub CommandButton1_Click()
Dim zeile As Long, wert$
On Error GoTo Fehler
zeile = ListBox1.ListIndex
'Den Pfad vervollständigen.
'Bsp.: In Spalte 3 der Listbox steht 'Kaffeetasse_blau'
'Der komplette Pfad ist aber 'L:\Bilder\Kaffeetass_blau.jpg'
wert = "L:\Bilder\" & ListBox1.List(zeile, 2) & ".jpg"
Image1.Picture = LoadPicture(wert)
Exit Sub
Fehler:
MsgBox "Es ist ein Fehler aufgetreten. " & vbCrLf & _
"Überprüfen Sie bitte ob die Pfadangabe korrekt ist oder ein Datenträger eingelegt wurde.", _
vbOKOnly + vbCritical, "Anwendungsfehler"
End Sub