![]() |
![]() |
Shape.StaticID
Property StaticID As Long
Member of Shape
The StaticID property returns an integer representing a unique ID number assigned to each shape.
The ID number does not change during the lifetime of a shape, so this number can always be used to identify a shape.
The StaticID property returns a read-only value.
The following code example stores the current selection in the array of the active page properties:
Sub SaveSelection() Dim s As Shape, n As Long ActivePage.Properties("StoredSelection", 0) = ActiveSelection.Shapes.Count n = 1 For Each s In ActiveSelection.Shapes ActivePage.Properties("StoredSelection", n) = s.StaticID ' Store the current shape's ID number n = n + 1 Next s End Sub
The followinge code example restores the selection saved in the properties of the active page in the previous example. You can use the Page.FindShape or Layer.FindShape methods to locate a shape based on its unique ID.
Sub RestoreSelection() Dim s As Shape, sr As New ShapeRange Dim v As Variant Dim Num As Long, i As Long, id As Long v = ActivePage.Properties("StoredSelection", 0) ' Retrieving the total number of shape references stored If Not IsNull(v) Then ActivePage.Properties.Delete "StoredSelection", 0 ' Delete the property Num = v For i = 1 To Num id = ActivePage.Properties("StoredSelection", i) ' Getting the current shape's ID to find Set s = ActivePage.FindShape(StaticID:=id) If Not s Is Nothing Then sr.Add s ' Add the shape to the shape range if it still exists in document ActivePage.Properties.Delete "StoredSelection", i ' Delete the property Next i sr.CreateSelection ' Selects all shapes found Else MsgBox "No selection stored in the active page" End If End Sub
![]() |
![]() |
![]() |
Copyright 2007 Corel Corporation. All rights reserved.