Sub CreateAndStoreShapes()
Dim i As Long
Dim x As Double, y As Double, r As Double
Dim MaxX As Double, MaxY As Double, MaxR As Double
Dim s As Shape, Num As Long
MaxX = ActivePage.SizeWidth
MaxY = ActivePage.SizeHeight
MaxR = 1
Num = 100
ActiveLayer.Properties("ShapeArray", 0) = Num ' Store the total number of shapes
For i = 1 To Num
x = Rnd() * MaxX
y = Rnd() * MaxY
r = Rnd() * MaxR
Set s = ActiveLayer.CreateEllipse2(x, y, r)
s.Fill.UniformColor.RGBAssign Rnd() * 256, Rnd() * 256, Rnd() * 256
ActiveLayer.Properties("ShapeArray", i) = s.StaticID ' Store the current shape's ID number
Next i
End Sub