OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 05-05-2014, 20:46
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Return text string by colour?

Suppose I have a word and the letters are different colours. How can I pull out the string for those coloured orange (CreateCMYKColor(0, 60, 100, 0)). I know how to process letters in a word one at a time but I'm looking to find strings of the same colour. Thanks
Reply With Quote
Old 06-05-2014, 00:44
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434

Well the following seems to be working but there must be a better way and I would like to know how to search for a colour without using it's name, eg Brown Old is cmyk(0,20,20,50)

Sub UpdateTextColour()

Dim wrd As String, t As String, s as Shape, p as Page

For Each p In ActiveDocument.pages

    For Each s In p.Shapes
    If s.Type = cdrTextShape Then
        n = s.text.Story.Length
        wrd = s.text.Story
        For i = 0 To n - 1
        n = 0
        If s.text.Range(i, i + 1).Fill.UniformColor.name = "Brown Old" Then
            n = 1
            If s.text.Range(i + 1, i + 2).Fill.UniformColor.name = "Brown Old" Then
                n = 2
                If s.text.Range(i + 1, i + 3).Fill.UniformColor.name = "Brown Old" Then
                    n = 3
                    If s.text.Range(i + 1, i + 4).Fill.UniformColor.name = "Brown Old" Then n = 4
                    End If
                    End If
                    End If
        If n > 0 Then
            t = s.text.Range(i, i + n)
            choice = MsgBox("YES: Brown" + Chr(13) + Chr(13) + "  No: Grey", vbYesNo, "Select Colour of " + t + " in " + wrd)
            If choice = vbYes Then s.text.Range(i, i + n).Fill.UniformColor.CMYKAssign 10, 80, 90, 40
            If choice = vbNo Then s.text.Range(i, i + n).Fill.UniformColor.CMYKAssign 0, 0, 0, 80
            i = i + n
        End If
    End If
    Next s
Next p

MsgBox "Done!"

End Sub
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Document.FullFileName return empty string coreldrawer Macros/Add-ons 0 15-05-2013 08:19
Return Focus to Text Box cooloox CorelDRAW/Corel DESIGNER VBA 4 31-03-2009 04:25
Randomising a text string knowbodynow CorelDRAW/Corel DESIGNER VBA 3 07-05-2006 08:15
Changing Colour of Characters in Artistic text knowbodynow CorelDRAW/Corel DESIGNER VBA 3 06-05-2006 20:43
how do return architectural measurements in text box? xombie CorelDRAW/Corel DESIGNER VBA 4 15-03-2006 09:43

All times are GMT -5. The time now is 09:50.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com