Consulting

Results 1 to 13 of 13

Thread: Where Are the Hidden AutoShapes??

  1. #1

    Where Are the Hidden AutoShapes??

    I have had this problem a number of times over the years, and I still don?t understand it.

    Yesterday I did a count of all the AutoShapes on different sheets of a workbook using ActiveSheet.Shapes.Count, and it says that I have 2020 on one sheet and 1630 on another. Then I used ActiveSheet.DrawingObjects.Select to highlight all the ?objects? on each sheet. Visually there were not anywhere near as many ?objects? as the AutoShape count would indicate.

    Let me digress to say that I accidentally found over a thousand AutoShape block arrows (which I use a lot of on certain sheets) that were squashed down to nearly a one-line thickness and all on top of each other. I have a macro that will assist me in deleting such unwanted collections, so I was able to get rid of the group that I found. That?s when I decided to do a count. I have been having problems with ?Not enough resources to display?, and I am sure that the hidden AutoShapes are certainly a contributing factor to this nuisance.

    My question is, how do I find the hidden AutoShapes? Is there, for example, a way to find an AutoShape if I know its number? The shapes I deleted yesterday had large numbers like 6302, which is pretty scary. Anyone else ever have this problem?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Maybe this will help:

    [vba]

    Dim Shp As Shape

    For Each Shp In ActiveSheet.Shapes

    MsgBox Shp.TopLeftCell
    Shp.TopLeftCell.Select
    Stop

    next
    [/vba]

  3. #3
    Hi, Jake! Thanx for the suggestion ... looks like a winner.
    Sid

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Glad to help.

    Well at least that will tell you where it is at. You can also add lines to change the size so you can see it (if it is shrunk down).

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sid,
    How about some code to delete all shapes entirely contained in a range of cells.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6

    Solved (Somewhat)

    OK, with help from you guys I have successfully written several macros to investigate the "hidden" AutoShapes.
    I know where they are, what they are, and their numbers.
    I also have a macro to delete large numbers of them that I have used successfully in the past.

    Regretably, I found that I can neither see nor delete most of them. Some of them are identified as "Lines", whatever that means. All I see is blank space. Since this is not a new problem, I do know what to look for ... they just aren't there, and since I am unable to delete them by specifying their AutoShape numbers, I have to presume that the worksheets have been corrupted in some fashion. The few objects that I did delete reduced the workbook size significantly, so I know that's what causing the "out of resources" errors. Pffft!

    Thank you all for your able assistance. It's been a good education!

  7. #7
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Sid,

    Yes, I've also had this problem in the past and it's a real PITA. From memory, I think I got the problem by deleting rows that had some out-of-sight shapes such as text boxes somewhere on them (or some may've been squashed up to the thickness of a line). The rows are deleted but the shapes were not cut before deleting, so somewhere deep in the recesses of the machines memory it's obediantly saving up all these invisible and unobtainable shapes for me. So yes, in effect you could say the worsheet's been corrupted.

    Now, just to be sure, I always make sure I cut all shapes and do a save before deleting any rows.

    HTH,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  8. #8
    Thanks for the reply, John. I think what you described is what has happened. I tend to be negligent at times about deleting AutoShapes before deleting lines and sheets. I suspect that deleting sheets can also cause the problem. But I'm learning the hard way. I convinced more people have the same problem than they realize.

  9. #9
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by Cyberdude
    ... I convinced more people have the same problem than they realize.
    Actually, you're right Sid. This whole discussion brought to mind a part of a problem I had with someones workbook on another forum.

    As it was, it showed the workbook was 5+MB and was as slow-as. Considering the amount of data in it, 5+MB was quite unbelievable. I ran Jakes clean-up macro which brought it back to 1.5MB - but that was still way too much.

    So, following this discussion, I just now copied and special-pasted the row headers and their formats (and the single line of code) from what I suspected was the problem sheet to a new sheet (n.b. this was all that was on that sheet). Deleted the original sheet and saved - Voila! what was 1.5MB instantly became 83Kb and is now FAST!!
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  10. #10
    John, if you think that a 5 Mb book is large, I was having trouble with one that was about 7.5 Mb for no discernable reason. I kept running out of resources to display. So I ran my diagnostic macro and found that there were 20,836 RightArrows lurking in there somewhere. That was too big a job to track down and delete those shapes, so I had to rebuild the sheet this weekend. The book is now about 3.5 MB. No more out of resources complaints.

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I had to split one of my workbooks when it reached 27.5MB with no shapes at all. The only problem was that macros ran exceedingly slowly when it was open. I've no problem now with the 16.5 & 10MB resultant books, although as my data accumulates weekly, I'll have to keep an eye on them!
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by Cyberdude
    John, if you think that a 5 Mb book is large, I was having trouble with one that was about 7.5 Mb for no discernable reason. I kept running out of resources to display. So I ran my diagnostic macro and found that there were 20,836 RightArrows lurking in there somewhere. That was too big a job to track down and delete those shapes, so I had to rebuild the sheet this weekend. The book is now about 3.5 MB. No more out of resources complaints.
    Sid,

    It wasn't that I thought 5MB was large in itself, it was just large when you considered what this particular workbook actually contained - bugger all.

    I've since found the OP was manually pasting thousands of lines into the book to do their calculations in it, and then (after printing {I assume}) clearing the contents for another paste etc. As we really don't know exactly what's being pasted every time - could be styles, formats, shapes etc. if they're doing a straight paste, the worksheet could quite easily become bloated. So for now I've just altered their code to delete (instead of clear) all pasted rows after they run their procedure. But I'd really like to get them to always do their copy and paste via a procedure so there's some control (by always using paste special) over what's being pasted
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  13. #13
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    What about making the shapes bigger so you can find them easier???

    [vba]Sub test()
    Dim objShape As Shape

    For Each objShape In ActiveSheet.Shapes
    objShape.ScaleHeight 15, msoFalse
    objShape.ScaleWidth 15, msoFalse
    Next objShape

    End Sub[/vba] Yes? No?




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

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