Color property example

Private Sub ColorExample()

'This example demonstrates how to return and change the Color property.

     Dim ents As Object

     Dim ent As Object

     Dim NewColor As Integer

     Dim Response

     Dim ct As Long

Dim x as Long

     Set ents = ActiveDocument.ModelSpace

     ct = ents.Count

     MsgBox "No. of entities = " & ct

     

     For x = 1 To ct

     Set ent = ents.Item(x)

          Response = MsgBox("Color of entity is: " & ent.Color & Chr(13) & "Do you want to change it?", vbYesNo, "Color of Entities")

          If Response = vbYes Then

               NewColor = InputBox("New color [0-256]:")

               ent.Color = NewColor

               ent.Update

          End If

          ' Display message.

          Response = MsgBox("Continue listing entities?", vbYesNo, "Color of Entities")

          If Response = vbNo Then GoTo Regener

     Next x

Regener:

' User chose to exit.

     End

End Sub