Delete earlier 'Picture' version when new picture copied in
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? |
Delete earlier 'Picture' version when new picture copied in
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? |
All times are GMT +1. The time now is 12:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com