Remove background image with VB

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
I have created a process where I use a background image and then add multiple text in various cells. I do this for about 10 sheets on a regular basis.
When I have to to rerun the process, I have to manually delete the background on each sheet first since the image name increments each time to a new one

Is there a way to simply "remove background image if it exists"
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

patrickmuldoon99

Active Member
Joined
Jun 27, 2006
Messages
345
I don't know the direct code, but surely you could find it out by recording yourself removing the background image.

Then, if there is the possibility that there will be no background image to remove, you can include the line

Code:
on error resume next

after you have included the recorded instruction of removing the background image.


Hope this helps

Patrick
 

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
When one records the delete of a background it looks like this

ActiveSheet.Shapes("Picture 49").Select
Selection.Delete

The problem is that the actual name "Picture 49" will be "Picture 50" the next time, etc. It is different on each sheet.

I need to find out how the get that name and then substitute that into the select statement
 

patrickmuldoon99

Active Member
Joined
Jun 27, 2006
Messages
345
Ah right, i'm with you.

Well you could iterate through the workbooks shapes collection... are the shapes that are the background the only objects with "Picture" starting the name?

If so, we could iterate through activesheet.shapes and simply delete all images on the sheet.
 

Forum statistics

Threads
1,141,011
Messages
5,703,724
Members
421,311
Latest member
tanujath

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top