Gruppe
Grafik
Problem
Bei Doppelklick in Spalte A soll das in der aktiven Zelle genannte, im gleichen Verzeichnis wie diese Datei liegende Bild in einen Zellkommentar eingefügt werden.
ClassModule: DieseArbeitsmappe
Private Sub Workbook_Open()
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
End Sub
ClassModule: Tabelle1
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim pct As Picture
Dim cmt As Comment
Dim sPath As String
If Target.Column <> 1 Then Exit Sub
If IsEmpty(Target) Then Exit Sub
Application.ScreenUpdating = False
Cancel = True
If Not Target.Comment Is Nothing Then
Target.Comment.Delete
Exit Sub
End If
sPath = ThisWorkbook.Path & "\"
If Dir(sPath & Target.Value) = "" Then
Beep
MsgBox "Bilddatei wurde nicht gefunden!"
Exit Sub
End If
Set pct = ActiveSheet.Pictures.Insert(sPath & Target.Value)
Set cmt = Target.AddComment
With cmt.Shape
.Width = pct.Width
.Height = pct.Height
With .Line
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.BackColor.RGB = RGB(255, 255, 255)
End With
With .Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 255)
.BackColor.SchemeColor = 80
.Transparency = 0#
.UserPicture sPath & Target.Value
End With
End With
pct.Delete
Application.ScreenUpdating = True
End Sub