Hi everyone,
I used some codes to insert a picture in a sheet. Then later I want to delete it, but leave the command button. I tried 3 different codes but none of them works.
This one doesn't do anything
This one says "Type mismatch"
This one delete both the picture and my command button
And here is my code to add the picture in if that helps.
Thank you all in advance
I used some codes to insert a picture in a sheet. Then later I want to delete it, but leave the command button. I tried 3 different codes but none of them works.
This one doesn't do anything
VBA Code:
Dim Pic As Shape
For Each Pic In ActiveSheet.Shapes
If Pic.Type = msoPicture Then
Pic.Delete
End If
Next
This one says "Type mismatch"
VBA Code:
Dim Pic As Picture
For Each Pic In ActiveSheet.Pictures
Pic.Delete
Next
This one delete both the picture and my command button
VBA Code:
Activesheet.Pictures.Delete
And here is my code to add the picture in if that helps.
VBA Code:
Sub Present_Pic()
If PicPath = "" Then Exit Sub
Dim Pic As Picture, ImageCell As Range
Set ImageCell = Interface.Cells(20, 8)
Set Pic = Interface.Pictures.Insert(PicPath)
With Pic
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = 400
End With
Set Pic = Nothing
End Sub
Thank you all in advance