![]() |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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
|
|
#3
|
|||
|
|||
|
Alex,
sorry for my late response. This did help! Thank you very much.
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |