Hi all,

I want to insert a picture of a particular student after entering a roll no. of him in cell ‘g7’ automatically. If I enter a roll no. in cell ‘g7’ and hid enter key then the photograph of that particular student should insert in cell ‘e2’ automatically.

I want to delete a picture from ‘e2’ first and then want to insert a picture in it.
The code for inserting picture is working fine but the code for deleting the picture first is not working. I am getting compile error ‘438 object doesn’t support this property or method’

Sub InsertImage()

Dim Pic As Object
For Each Pic In ActiveSheet.Range("e2").Pictures
Pic.Delete
Next Pic

Range("E2").Select 'This is where picture will be inserted
Dim picname As String
picname = InputBox("enter picname to insert.")
ActiveSheet.Pictures.Insert("C:\IMAGES\" & picname & ".jpg").Select

' This resizes the picture

With Selection
.Left = Range("E2").Left
.Top = Range("E2").Top
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 100#
.ShapeRange.Width = 80#
.ShapeRange.Rotation = 0#
End With

Range("A10").Select
Application.ScreenUpdating = True
MsgBox "Done!", 64
Exit Sub

ErrNoPhoto:
MsgBox "Unable to Find Photo"
Exit Sub
Range("B20").Select

End Sub
Any help will be appreciated.

Thanking you,