Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing a picture box from an Excel 2007 spreadsheet SMG Excel Worksheet Functions 6 February 13th 09 08:46 AM
Removing a picture box in Excell 2007 SMG Excel Discussion (Misc queries) 0 February 13th 09 12:40 AM
How to extract a picture from an Excel worksheet into a picture fi SARANJAI Excel Discussion (Misc queries) 10 June 12th 05 05:00 AM
How to retrieve the name of a picture within a worksheet? Oscar Excel Programming 3 January 5th 04 01:39 AM
Removing Picture from Cell Command Bar Bernie Deitrick[_2_] Excel Programming 0 August 8th 03 02:59 PM


All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"