Consulting

Results 1 to 4 of 4

Thread: how to chose the shape with cmyk and name it

  1. #1
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    2
    Location

    how to chose the shape with cmyk and name it

    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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    2
    Location
    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.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •