Sub DeleteImage(ByVal sName As String)
'This sub will erase the image named "sName" from the drawing an also will detach it.
On Error GoTo NoSuchRaster
' Get the Image Dictionary.
Dim oImageDictionary As AcadDictionary
Set oImageDictionary = ThisDrawing.Dictionaries("ACAD_IMAGE_DICT")
' Get the raster definition
Dim oImageDef As AcadObject
Set oImageDef = oImageDictionary(sName)
' Erase the image's definition
oImageDef.Delete
NoSuchRaster:
'If there is any error, the raster does not exist.
' Destroy created objects
Set oImageDictionary = Nothing
Set oImageDef = Nothing
End Sub