reseting hidden shape counter

S

scattered

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
 
J

jasontferrell

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top