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
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
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:
The following macro shows how the function might be used: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
Sub Test() MsgBox CMYKtoRGB(0, 0.498, 1, 0) End Sub
Cheers
Paul Edstein
[Fmr MS MVP - Word]
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.
Last edited by shanda; 09-08-2017 at 05:53 AM.
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
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3