How do I delete an embedded picture on a worksheet using VBA?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My VBA routine copies an embedded chart from a worksheet to another worksheet
as a picture (CopyPicture). This works fine but I want to clear the picture
from the destination worksheet before copying anouther picture to it, so the
pictures don't build up. I can't seem to find a way to activate the picture
via VBA so that it can be deleted.
 
Try something like the following:

Dim ChtObj As ChartObject
Dim Pict As Picture
Set ChtObj = Worksheets(1).ChartObjects(1)
ChtObj.CopyPicture xlScreen
On Error Resume Next
Worksheets("sheet2").Pictures(1).Delete
On Error GoTo 0
Worksheets("Sheet2").Paste


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
does this help?

Sub findPicturename()
msn = "Picture " & ActiveSheet.Shapes.Count
MsgBox msn
ActiveSheet.Shapes(msn).Cut 'Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top