Private Sub CountExample()
' This example demonstrates how to count the number of entities using
' the Count property. It also uses the Item property to return the
' next-to-last entity and change the color of this entity.
Dim ents As Object
Dim ent As Object
Dim ct As Long
Set ents = ActiveDocument.ModelSpace
ct = ents.Count
MsgBox "No. of entities = " & ct
Set ent = ents.Item(ct - 1)
MsgBox "Color of this entity is now: " & ent.Color
ent.Color = 3
MsgBox "Color of this entity has been changed to: " & ent.Color
ent.Update
End Sub