ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reseting hidden shape counter (https://www.excelbanter.com/excel-programming/425938-reseting-hidden-shape-counter.html)

scattered[_4_]

reseting hidden shape counter
 
Greetings,

I have a program that (as part of an animation involving vectors in a
plane) creates then deletes a large number of arrows on a chart. It
works fine, but when I click on one of the arrows I see that its name
is something like "Line 5265" even though there are only 2 vectors
actually in existence (so that myChart.Shapes.Count correctly gives
2). It seems weird that the Count property is reset upon delete but
that there is some behind-the-scenes counter which isn't reset. This
isn't pressing since I don't use the name in my code (and know how to
change it if I needed to - which, by the way, doesn't reset this
hidden counter either) but have a concern that maybe the code will
crash after 65536 lines have been created (and mostly deleted) since
for all I know there is a 16-bit int counter in the code for Excel
which will trigger a bug upon overflow. Is there any way to reset the
numbering so that the default numbering of a new shape only depends on
the current count? Also- is there anything behind my fear that
eventually such large numbers in the shape name might lead to a
harmful overflow? Just curious.

-scattered

jasontferrell

reseting hidden shape counter
 
That is a lot of lines. I just tried creating and deleting about
70,000 lines on a worksheet. I left the last 3 lines and they indeed
have names of "Line 70004" and the like. The shapes.count is only 3,
however, and it did not crash. I am using Excel 2003.
You can also change the "name" property by just setting it like this:
Dim sLine As Shape
sLine.Name = "Line " & lCount
Just don't try to set the name to the same name as another object.



All times are GMT +1. The time now is 05:19 AM.

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