OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27-04-2004, 07:07
joexx
Guest
 
Posts: n/a
Default Select Paragraph Text with more than one color

I have a document with 10 different black paragraph texts.
One of them has one word with red fill color.

Is ist possible to, find this text with the two colors?
(Corel 11)

Thanks
Reply With Quote
  #2  
Old 27-04-2004, 10:14
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,932
Blog Entries: 4
Default Re: Select Paragraph Text with more than one color

The first thing that comes to my mind would be to go through each text object letter by letter and inspect their fills and see if your color pops up...

Here is an example of how you can implement this. The following macro goes through all text objects and looks for characters that have red in their fill. It checks uniform, fountain and two color pattern fills. All parts of the code eventually call CheckColor function which should return True is the color of interest is found. I'm looking for CMYK red by getting the string with color components and comparing against my known color string ("C:0 M:100 Y:100 K:0"). It's a simple and efficient ways of comparing colors if you don't know their color models, etc.

Another way of comparing colors could be creating your sample color and then call Color.IsSame method which will do the comparisons. But I find it is much simpler to look for just the color component string.

I hope this helps:

Code:
Option Explicit

Sub SelectAllRedText()
    Dim s As Shape
    Dim sr As New ShapeRange
    For Each s In ActivePage.FindShapes(Type:=cdrTextShape)
        If CheckTextFill(s) Then sr.Add s
    Next s
    sr.CreateSelection
End Sub

Private Function CheckTextFill(ByVal s As Shape) As Boolean
    Dim ch As TextRange
    Dim bFoundRed As Boolean
    
    bFoundRed = False
    For Each ch In s.Text.Story.Characters
        If CheckFill(ch.Fill) Then
            bFoundRed = True
            Exit For
        End If
    Next ch
    CheckTextFill = bFoundRed
End Function

Private Function CheckFill(ByVal f As Fill) As Boolean
    Dim fc As FountainColor
    Dim bFoundRed As Boolean
    Select Case f.Type
        Case cdrUniformFill
            bFoundRed = CheckColor(f.UniformColor)
            
        Case cdrFountainFill
            bFoundRed = CheckColor(f.Fountain.StartColor)
            If Not bFoundRed Then
                bFoundRed = CheckColor(f.Fountain.StartColor)
            End If
            If Not bFoundRed Then
                For Each fc In f.Fountain.Colors
                    bFoundRed = CheckColor(fc.Color)
                    If bFoundRed Then Exit For
                Next fc
            End If
            
        Case cdrPatternFill
            If f.Pattern.Type = cdrTwoColorPattern Then
                bFoundRed = CheckColor(f.Pattern.FrontColor)
                If Not bFoundRed Then
                    bFoundRed = CheckColor(f.Pattern.BackColor)
                End If
            End If
    End Select
    CheckFill = bFoundRed
End Function

Private Function CheckColor(ByVal c As Color) As Boolean
    CheckColor = (c.Name(True) = "C:0 M:100 Y:100 K:0")
End Function
Reply With Quote
  #3  
Old 06-10-2004, 12:20
joexx
Guest
 
Posts: n/a
Default

Alex,

sorry for my late response.
This did help! Thank you very much.
Reply With Quote
Reply


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
Panic !!!!!! Paragraph text, frame height Bellekom CorelDRAW/Corel DESIGNER VBA 4 11-05-2004 06:03
Paragraph text like Ingredient List d-signer CorelDRAW/Corel DESIGNER VBA 2 22-01-2004 21:59
Resizing a Paragraph text box Steege CorelDRAW CS 1 17-01-2004 04:24
Paragraph text problem ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 13-01-2004 08:50
Artistic Text or paragraph invisible after upgrade to v11 ?? tuxedo21 CorelDRAW/Corel DESIGNER VBA 0 26-08-2003 16:27


All times are GMT -5. The time now is 16:02.


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