1

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

user3422687
  • 229
  • 1
  • 8
  • 27
  • Why not to use native search by color? – omegastripes Jan 09 '19 at 09:22
  • Sorry not really an answer but I don't know much about coreldraw. Is the VBA for coreldraw that much different than VBA in excel? Like does the `Split` function not exist in corel draw? If it does you can easily get the 4 digits between the 2nd and 6th comma using the split function. – RCL Jan 09 '19 at 09:40
  • thanks for the comments Coreldraw VBA doesn't have all the commands excel does but in my case all the examples I found use cell references. I will try some research on the spilt function but didn't think it allowed splitting between deliminator – user3422687 Jan 09 '19 at 12:11
  • excuse my ignorance but what is the native search by color? – user3422687 Jan 09 '19 at 12:35

1 Answers1

0

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
omegastripes
  • 12,351
  • 4
  • 45
  • 96