ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem - Deleting a Picture from a Cell (https://www.excelbanter.com/excel-programming/272151-re-problem-deleting-picture-cell.html)

Tom Ogilvy

Problem - Deleting a Picture from a Cell
 
You are starting with an incorrect perception. Pictures are on a different
layer than cells. They may sit over a cell, but they are not in the cell.
You would need to loop and find the picture

Sub DeletePicture()
Dim pic As OLEObject
For Each pic In ActiveSheet.Pictures
If pic.TopLeftCell.Address = _
Cells(10, 1).Address Then
pic.Delete
End If
Next
End Sub

--
Regards,
Tom Ogilvy



general zod wrote in message
...

I have inserted a small picture (jpg) into cell (a1)


and I have used the following excel 97 VBA code to copy that picture
into cell a10


Cells(1, 1).Select

Cells(1, 1).CopyPicture

Cells(10, 1).PasteSpecial


Does anyone know the VBA code to then delete the picture from cell
(10,1) A10 ????

Cells(10,1).delete just deletes the cell , it leaves the picture
there ?


.




general zod

Problem - Deleting a Picture from a Cell
 
I stand corrected !! , thankyou very much - appreciated


On Sun, 20 Jul 2003 13:37:55 -0400, "Tom Ogilvy"
wrote:

You are starting with an incorrect perception. Pictures are on a different
layer than cells. They may sit over a cell, but they are not in the cell.
You would need to loop and find the picture

Sub DeletePicture()
Dim pic As OLEObject
For Each pic In ActiveSheet.Pictures
If pic.TopLeftCell.Address = _
Cells(10, 1).Address Then
pic.Delete
End If
Next
End Sub




All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com