Delete earlier 'Picture' version when new picture copied in

J

JDaywalt

I have a sheet tab that contains data + one Picture object. I have a macro
that allows users to copy/paste this data onto a master sheet tab that may be
blank (if it is the first copy), or it may contain previously copied data.
Over time, the user will likely use this copy/paste process many times. The
issue is that with each copy/paste, the newest version of both the data &
picture are copied over the previous. This is no problem for the data as it
just overwrites the previous, however, the picture 'pastes' over the top of
the old one, leaving each previous version underneath. For example, the
first copy will be labeled as 'Picture 1', the next copy will become 'Picture
2', then 'Picture 3', etc. Over time, the file will become huge as each
picture object gets stacked on top of the other. What code can I write that
will help recognize & delete a previous version of the picture if it exists?
 
J

Jim Cone

Sub xxx()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If InStr(1, shp.Name, "Picture", vbTextCompare) > 0 Then
shp.Delete
End If
Next 'shp
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"JDaywalt"
wrote in message
I have a sheet tab that contains data + one Picture object. I have a macro
that allows users to copy/paste this data onto a master sheet tab that may be
blank (if it is the first copy), or it may contain previously copied data.
Over time, the user will likely use this copy/paste process many times. The
issue is that with each copy/paste, the newest version of both the data &
picture are copied over the previous. This is no problem for the data as it
just overwrites the previous, however, the picture 'pastes' over the top of
the old one, leaving each previous version underneath. For example, the
first copy will be labeled as 'Picture 1', the next copy will become 'Picture
2', then 'Picture 3', etc. Over time, the file will become huge as each
picture object gets stacked on top of the other. What code can I write that
will help recognize & delete a previous version of the picture if it exists?
 

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

Top