Shape.ID is it unique - when is it set - when does it change

L

lahd

Hi

I would like a way to uniquely identify shapes within a workbook. Is the ID
property of Shape unique? Is it only assigned when the shape is created? Is
there any other way it can be changed? I'm trying to make sure that it is a
good property to use as a unique identifier. Thanks,

Dave
 
D

Don Guillett

Select the shape and look in the name box to the left of the formula box. Go
there and change the name to whatever desired and touch the enter key.
 
L

lahd

Yes, that is the problem. I'm doing this programmatically and I want a
unique identifier for the shape. Is the ID property of the Shape object
unique? The name is not and can be set by the user...
 
P

Peter T

AFAIK the shape's ID property is unique within the workbook and remains
constant while on its original sheet. A new shape will not be given the same
ID of some deleted shape

You can't directly refer to a shape by it's ID property, would need to loop
something like this

For each shp in Activesheet.shapes
If shp.ID = 1234 then
bFound = True
Exit For
Next
If bFound then
Msgbox shp.name
End If

The shape ID property is n/a in older Excel versions, I think introduced in
XP

Regards,
Peter T
 

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