Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default verify a shape exists in the sheet

Hi,

I am trying to delete a shape from a sheet with:

ActiveSheet.Shapes("AAPicture").Select
Selection.Delete

I need to verify first that the shape exists so the user wont get an
error that the object doesnt exists.

How can i do that?

Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default verify a shape exists in the sheet

Hi vandaley

One way is to use on error

On Error Resume Next
ActiveSheet.Shapes("AAPicture").Delete
On Error GoTo 0


--
Regards Ron de Bruin
http://www.rondebruin.nl



"vandaley" wrote in message ups.com...
Hi,

I am trying to delete a shape from a sheet with:

ActiveSheet.Shapes("AAPicture").Select
Selection.Delete

I need to verify first that the shape exists so the user wont get an
error that the object doesnt exists.

How can i do that?

Thanks,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default verify a shape exists in the sheet

Hi,

how about this one:

Dim s As Shape
For Each s In ActiveSheet.Shapes
If s.Name = "Test" Then
MsgBox "shape Test exists"
exit for
End If
Next

"Name" seems to be case sensitive.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default verify a shape exists in the sheet

Thanks ,

Seems to do the trick.
Ron de Bruin wrote:
Hi vandaley

One way is to use on error

On Error Resume Next
ActiveSheet.Shapes("AAPicture").Delete
On Error GoTo 0


--
Regards Ron de Bruin
http://www.rondebruin.nl



"vandaley" wrote in message ups.com...
Hi,

I am trying to delete a shape from a sheet with:

ActiveSheet.Shapes("AAPicture").Select
Selection.Delete

I need to verify first that the shape exists so the user wont get an
error that the object doesnt exists.

How can i do that?

Thanks,


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
verify if spesific sheet exist Miri Excel Discussion (Misc queries) 3 February 26th 07 01:04 PM
verify a path exists JLGWhiz Excel Programming 13 August 24th 06 11:13 PM
Verify if sheet name still exist Edmund Excel Programming 9 July 11th 06 05:08 PM
How can I know if a sheet exists ? Ben.C Excel Programming 3 December 29th 03 09:36 AM
Verify a directory exists MacroMan[_4_] Excel Programming 3 August 8th 03 04:38 PM


All times are GMT +1. The time now is 07:38 PM.

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"