ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming Shapes (https://www.excelbanter.com/excel-programming/406040-programming-shapes.html)

Gary

Programming Shapes
 
I have some code that deletes shapes by selecting individual shapes then
deleting them prior to sending document in an email to another division.
Unfortunately, I found out today that if the shape somehow was deleted, the
macro blows up. I need something like:

If shape exists then
select shape
delete shape
end if

I can't figure out how to determine if the shape exists. Another
possibility, I suppose, is to check for an error on delete, but I'm not sure
how to do this.

Thanks,
Gary
--
To learn is to live.

Don Guillett

Programming Shapes
 

You fail to show your code but
on error resume next
or
sub delshps()
for each sh in activeworksheet.shapes
sh.delete
next sh
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary" wrote in message
...
I have some code that deletes shapes by selecting individual shapes then
deleting them prior to sending document in an email to another division.
Unfortunately, I found out today that if the shape somehow was deleted,
the
macro blows up. I need something like:

If shape exists then
select shape
delete shape
end if

I can't figure out how to determine if the shape exists. Another
possibility, I suppose, is to check for an error on delete, but I'm not
sure
how to do this.

Thanks,
Gary
--
To learn is to live.



Gary

Programming Shapes
 
A most excellent answer. I will never forget the on error resume next
solution.
--
To learn is to live.


"Don Guillett" wrote:


You fail to show your code but
on error resume next
or
sub delshps()
for each sh in activeworksheet.shapes
sh.delete
next sh
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary" wrote in message
...
I have some code that deletes shapes by selecting individual shapes then
deleting them prior to sending document in an email to another division.
Unfortunately, I found out today that if the shape somehow was deleted,
the
macro blows up. I need something like:

If shape exists then
select shape
delete shape
end if

I can't figure out how to determine if the shape exists. Another
possibility, I suppose, is to check for an error on delete, but I'm not
sure
how to do this.

Thanks,
Gary
--
To learn is to live.




Don Guillett

Programming Shapes
 
Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary" wrote in message
...
A most excellent answer. I will never forget the on error resume next
solution.
--
To learn is to live.


"Don Guillett" wrote:


You fail to show your code but
on error resume next
or
sub delshps()
for each sh in activeworksheet.shapes
sh.delete
next sh
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary" wrote in message
...
I have some code that deletes shapes by selecting individual shapes then
deleting them prior to sending document in an email to another
division.
Unfortunately, I found out today that if the shape somehow was deleted,
the
macro blows up. I need something like:

If shape exists then
select shape
delete shape
end if

I can't figure out how to determine if the shape exists. Another
possibility, I suppose, is to check for an error on delete, but I'm not
sure
how to do this.

Thanks,
Gary
--
To learn is to live.






All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com