PDA

View Full Version : how to chose the shape with cmyk and name it



shanda
09-07-2017, 10:52 PM
sub rename()
dim lyr as layer
dim s1 as shape

for each s1 in lyr.shapes

if s1.fill.color = ??? then

s1.name = ???

end if

next

end sub


''''''''thanks

macropod
09-08-2017, 12:16 AM
Office only works with the RGB colours. If you're starting with CMYK colours, you'll need to do a CMYK>RGB conversion, for which you could use a function like:

Function CMYKtoRGB(C As Single, M As Single, Y As Single, K As Single) As String
Dim R As Long, G As Long, B As Long
C = (C * (1 - K) + K)
M = (M * (1 - K) + K)
Y = (Y * (1 - K) + K)
R = (1 - C) * 255
G = (1 - M) * 255
B = (1 - Y) * 255
CMYKtoRGB = "R: " & R & vbTab & "G: " & G & vbTab & "B: " & B
End Function
The following macro shows how the function might be used:

Sub Test()
MsgBox CMYKtoRGB(0, 0.498, 1, 0)
End Sub

shanda
09-08-2017, 05:35 AM
Thank you for your help!
This code run in Coreldraw ,i try to write code like this:

if s1.fill.uniformcolor = "0 0 70 0" then
s1.name = "shape1"
end if

but there is no response.

Paul_Hossler
09-08-2017, 01:44 PM
I don't use Corel, but I'd guess something like these




Function CMYKtoRGB(C As Single, M As Single, Y As Single, K As Single) As Long
Dim R As Long, G As Long, B As Long
C = (C * (1 - K) + K)
M = (M * (1 - K) + K)
Y = (Y * (1 - K) + K)
R = (1 - C) * 255
G = (1 - M) * 255
B = (1 - Y) * 255
CMYKtoRGB = RGB(R, G, B)
End Function







if s1.fill.uniformcolor = CMYKtoRGB (0, 0, 70, 0) then
s1.name = "shape1"
end if