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

  • Thread starter Thread starter lahd
  • Start date Start date
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
 
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.
 
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...
 
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
 
Back
Top