Object Model Reference : Classes : C : Color : Methods : Color.CopyAssign |
Sub CopyAssign(Color As Color)
Member of Color
The CopyAssign method copies the color model properties from a color object and applies them to the active color in CorelDRAW.
A color is an effect applied to an object that alters the objects appearance by the way it reflects light. A color model is a system that defines the number and type of colors that make up an image and that is used to organize and define colors according to a set of basic properties that can be reproduced. Black-and-white, grayscale, RGB, CMYK, and paletted are examples of popular color modes.
The following VBA example uses a separate Color object to take an objects fill color and convert it to RGB, then checks if the color is red (that is, its Red component value is greater than 150, and both Blue and Green values are less than 100). If this is the case, the object is filled with black. Otherwise, the objects fill remains unchanged.
Sub Test() |
Dim c As New Color |
Dim s As Shape |
For Each s In ActiveSelection.Shapes |
If s.Fill.Type = cdrUniformFill Then |
c.CopyAssign s.Fill.UniformColor |
c.ConvertToRGB |
If c.RGBRed > 150 And c.RGBGreen < 100 And c.RGBBlue < 100 Then |
s.Fill.UniformColor.RGBAssign 0, 0, 0 |
End If |
End If |
Next s |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.