Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing picture from a worksheet
Hi All,
I have about 90 different worksheets and majority of worksheets have a imagine file called 'picture 1'. All I am trying to do is delete this picture from every worksheets. So far I've done: For Each ws In ThisWorkbook.Worksheets Set DelPic = ws.Shapes("Picture 1") 'DelPic.Delete Next This macro runs fine if there is a picture 1 in the worksheet but because some of the worksheets don't really have a picture. It creates an error. How do I condition it so it only deletes 'picture 1' if there is one in the worksheet? Thank you so much Regards James |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing picture from a worksheet
In message
s.com of Sun, 14 Feb 2010 21:47:24 in microsoft.public.excel.programmin g, James writes Hi All, I have about 90 different worksheets and majority of worksheets have a imagine file called 'picture 1'. All I am trying to do is delete this picture from every worksheets. So far I've done: For Each ws In ThisWorkbook.Worksheets Set DelPic = ws.Shapes("Picture 1") 'DelPic.Delete Next This macro runs fine if there is a picture 1 in the worksheet but because some of the worksheets don't really have a picture. It creates an error. How do I condition it so it only deletes 'picture 1' if there is one in the worksheet? You might try: On Error Resume Next ' Ignore ALL errors For Each ws In ThisWorkbook.Worksheets ws.Shapes("Picture 1").Delete ' Try merging Set and Delete Next ws On Error GoTo 0 ' Restore default error handling -- Walter Briscoe |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing picture from a worksheet
Here is a method to do this without error checking...
Dim WS As Worksheet, SH As Shape ....... ....... For Each WS In ThisWorkbook.Worksheets For Each SH In WS.Shapes If SH.Name = "Picture 1" Then SH.Delete Exit For End If Next Next -- Rick (MVP - Excel) "Walter Briscoe" wrote in message ... In message s.com of Sun, 14 Feb 2010 21:47:24 in microsoft.public.excel.programmin g, James writes Hi All, I have about 90 different worksheets and majority of worksheets have a imagine file called 'picture 1'. All I am trying to do is delete this picture from every worksheets. So far I've done: For Each ws In ThisWorkbook.Worksheets Set DelPic = ws.Shapes("Picture 1") 'DelPic.Delete Next This macro runs fine if there is a picture 1 in the worksheet but because some of the worksheets don't really have a picture. It creates an error. How do I condition it so it only deletes 'picture 1' if there is one in the worksheet? You might try: On Error Resume Next ' Ignore ALL errors For Each ws In ThisWorkbook.Worksheets ws.Shapes("Picture 1").Delete ' Try merging Set and Delete Next ws On Error GoTo 0 ' Restore default error handling -- Walter Briscoe |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Removing a picture box from an Excel 2007 spreadsheet | Excel Worksheet Functions | |||
Removing a picture box in Excell 2007 | Excel Discussion (Misc queries) | |||
How to extract a picture from an Excel worksheet into a picture fi | Excel Discussion (Misc queries) | |||
How to retrieve the name of a picture within a worksheet? | Excel Programming | |||
Removing Picture from Cell Command Bar | Excel Programming |