View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default verifying an object exists

You could just wrap the delete command in an on error resume next.

On Error Resume Next
'delete the shape
On Error Goto 0

Robin Hammond
www.enhanceddatasystems.com

"JT" wrote in message
...
I have a macro with two rectangles that I use as
pushbuttons on a worksheet. Each one has a unique macro
assigned to it.

Macro # 2 makes a copy of the activeworkbook and deletes
the rectangle assigned to Macro # 2 (on the saved copy).
I don't want users to have the option of making another
copy from the "saved" copy.

No problem, so far. However when I open the "saved" copy,
Macro # 1 is used to make a copy of the data and send as
an e-mail attachment. It also deletes the 2 rectangles.

However, if I try to run Macro # 1 (from the "saved" copy,
I get an error because it is trying to delete the second
rectangle (which has already been deleted when the
workbook is copied.)

If Macro # 1 is run from the original workbook, no problem
because both rectangles still exist.

Any suggestions on code to verify the existance of
rectangle 2 would be appreciated.

As always, thanks for the help.