What's wrong with the code?
I keep the image files with the correct names in the folder named "picture" under the folder where the workbook is located. but the choice doesn't work.
Your suggestions?
I keep the image files with the correct names in the folder named "picture" under the folder where the workbook is located. but the choice doesn't work.
Your suggestions?
VBA Code:
Private Sub LB5_Change()
Sheets("Kimlik").Range("I9") = LB5.Value
Dim ad As String
Dim ResimYolu As String
Dim Resim As Object
Dim Foto As Object
Dim ResimAlani As Range
Set ResimAlani = Sheets("Kimlik").Range("I33")
On Error Resume Next
Application.ScreenUpdating = False
For Each Foto In ActiveSheet.Pictures
If Not Intersect(Foto.TopLeftCell, ResimAlani) Is Nothing Then
Foto.Delete
End If
Next
Set ResimAlani = Nothing
ad = LB5.Value
ResimYolu = ActiveWorkbook.path & "\Resim\" & ad & ".png"
ResimEkle (ResimYolu)
End Sub
Sub ResimEkle(dosya As String)
If Dir(dosya) = "" Then Exit Sub
With Sheets("Kimlik").Pictures.Insert(dosya)
.Left = Cells(33, 9).Left
.Top = Cells(33, 9).Top
.ShapeRange.LockAspectRatio = True
End With
End Sub