+ Reply to Thread
Results 1 to 6 of 6

check if shape exists, then...

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    check if shape exists, then...

    Hi!

    I am currently using the following macro to delete all shapes in a range on my worksheets. However, recently I happen to run into error 1004 telling me that an object is missing... Interestingly enough, when I end the complete macro (of which this one is a part of, basically a whole bunch of individual macros all called one after another) and then call this specific macro by itself, it seems to work with no problem.

    Please Login or Register  to view this content.

    Well, since I cannot figure out what is going on, I would like to modify the macro above to firstly only run if the sheet name is either "VIP" - "PCP" - "LSG" or "Company", and secondly check if there actually IS any shape in the specified range before trying to delete it.

    Since I did not write this code, and I am not familiar with shapes in vba, I was wondering if someone could give me a hand on this?
    Thanks a lot!

    A2k

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: check if shape exists, then...

    You already are checking if the shape is in that range so I'm not sure what you mean? There's no need to select the shape before deleting it though.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: check if shape exists, then...

    well, technically its defining the remaining procedure for each shape in range. my guess is that I am experiencing troubles which somehow are related to the case if there is no shape in range, since I am getting a 1004 error, which is related to a missing object.

    This line is highlighted in the editor:
    Please Login or Register  to view this content.
    I already deleted all shapes in the form but cannot get past this error. I am just thinking that by more strictly defining the sheets it is supposed to run and to specifically let it check if there really is a shape in the range.

    Any ideas what that could be?
    Thanks,
    A2k

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: check if shape exists, then...

    Well, I would always recommend looping backwards when deleting:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: check if shape exists, then...

    still the same error: runtime error 1004 - application defined or object defined error.

    I seriously have no idea what that could be. It now doesnt work anymore no matter if it is started as part of the whole macro procedure or as an individual macro. Can I somehow skip this step if it returns an error?

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: check if shape exists, then...

    Is the sheet protected? Can you post a version with no data but with the shapes in place for testing?

+ 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