vbastringcolorsselectioncoreldraw

Coreldraw VBA select all colour CMYK


Guys i'm trying to select all colours of a certain colour in the current selection

I use the following to find out the all the colours in the selection

Dim s As Shape
Dim value As String, os As ShapeRange
Set os = ActiveSelectionRange
If os.Count < 1 Then MsgBox ("Nothing selected!"): Exit Sub
For Each s In os
value = s.Fill.UniformColor.ToString
MsgBox (value)
Next s

Problem is the value of the string is as follows

CMYK,USER,0,84,80,100,000000000-0000-0000-0000-00000000000

I need to extract the 4 digits between the 2nd and 6th comma so I have the cmyk colour and then i can do a find shapes using that

I have been looking for ideas on string manipulation in VB but they seem to be for excel and not coreldraw

Any Ideas??

Any help appreciated

Mark


Solution

  • Split is a native VBA function, as @RCL mentioned. Try the below example:

    Sub Test()
    
        Dim s As Shape
        Dim value As String
        Dim os As ShapeRange
        Dim tmp
    
        Set os = ActiveSelectionRange
        If os.Count < 1 Then MsgBox ("Nothing selected!"): Exit Sub
        For Each s In os
            value = s.Fill.UniformColor.ToString
            tmp = Split(value, ",")
            MsgBox tmp(2) & vbCrLf & tmp(3) & vbCrLf & tmp(4) & vbCrLf & tmp(5)
        Next s
    
    End Sub