+ Reply to Thread
Results 1 to 7 of 7

How to delete visible shapes with code

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    How to delete visible shapes with code

    Hi,

    Is there a way for code to delete all shapes that are visible on the sheet? Specifically, I want to delete any drawn arrows text boxes and that are visible on Sheet11.

    Thanks,

    Lawrence
    Last edited by skysurfer; 01-21-2011 at 12:35 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to delete visible shapes with code

    Hi Lawrence,

    One way...

    Please Login or Register  to view this content.
    Rgds

    .... sorry, just realised you asked about Visible shapes. How are you defining Visible? Shapes in Hidden columns or shapes that have a background colour the same as the sheet background?
    Last edited by Richard Buttrey; 01-20-2011 at 07:43 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How to delete visible shapes with code

    Richard,

    The shapes that are hidden are drawing objects like text boxes, as well as ActiveX and form controls. The only shape I want to be able to delete are arrows with a drawing text box inside.

    I am using the following code to hide shapes:

    Please Login or Register  to view this content.
    '
    Thanks!

    Lawrence



    Quote Originally Posted by Richard Buttrey View Post
    Hi Lawrence,

    One way...

    Please Login or Register  to view this content.
    Rgds

    .... sorry, just realised you asked about Visible shapes. How are you defining Visible? Shapes in Hidden columns or shapes that have a background colour the same as the sheet background?
    Last edited by skysurfer; 01-20-2011 at 08:46 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to delete visible shapes with code

    Hi,

    How about
    Please Login or Register  to view this content.
    It assumes you haven't changed the shape names from their default names which contain "Arrow"

  5. #5
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How to delete visible shapes with code

    Richard,

    Will that code delete every shape with the word arrow anywhere in the shape name? If so, I could also delete the drawing text box if that had the name arrow in it as well, yes?

    Just one little problem: I could delete shapes I know the names of, but a pokey user could spot the shape's name in the Name Box and for whatever reason change it. That's why I thought I could cast a broad net and delete every shape that is not hidden no matter what their names are.

    Is there any way to say if shapes hidden property = false, then delete it?

    Thanks for all your help!

    Lawrence

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: How to delete visible shapes with code

    Will delete visible items from the drawingobjects collection, which is not the same as shapes collection.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How to delete visible shapes with code

    Andy,

    I think you had an avatar showing you swinging in to save the day???

    Thank you!

    Lawrence



    Quote Originally Posted by Andy Pope View Post
    Will delete visible items from the drawingobjects collection, which is not the same as shapes collection.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1