OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   working with tables cql or not (http://forum.oberonplace.com/showthread.php?t=7470)

runflacruiser 18-01-2011 17:12

working with tables cql or not
 
Hi.
Any ideas I get a "Object no longer exists" with this code when more than one table is on the page?
The code is supposed to change all text in tables on the page to red.

Also is there any cql to narrow the shaperange down to only the text inside?

Thanks.
-John

Code:

Sub MyTableTextColorChanger()

    Dim s As Shape, sr As ShapeRange, i As Long, j As Long
    Dim sText As Shape, sSel As Shape
    Set sr = ActivePage.Shapes.FindShapes(Query:="@type='plugin:table'")

    For i = 1 To sr.count
        For j = 1 To sr(i).Custom.cells.count
                Set s = sr(i).Custom.cells(j).TextShape
                If s.Type <> cdrCustomShape And Len(s.text.Story.Characters.All) Then
                    s.Fill.UniformColor.RGBAssign 255, 0, 0
            End If
        Next j
        Set s = sr(i).Custom.cells(i).TextShape
    Next i
   
End Sub


shelbym 19-01-2011 01:38

CQL Tables Text
 
How about something like this:
Code:

Sub MyTableTextColorChanger()
    Dim s As Shape, sr As ShapeRange
   
    Set sr = ActivePage.Shapes.FindShapes(Query:="@type='plugin:table' and (@com.ParentGroup = null or @com.ParentGroup.Type <> 21)") 'Return just the tables
    Set sr = sr.Shapes.FindShapes(Query:="@type='text:paragraph' and !@com.Text.Story.Text.Trim().empty()") 'Find all text
   
    For Each s In sr
        s.Fill.UniformColor.RGBAssign 255, 0, 0
    Next s
End Sub

I have only tested in X5. Let me know if it doesn't work in X4 and I will try a different way.

-Shelby

runflacruiser 19-01-2011 08:39

Hi.
That's 100% exactly what I had in mind. I couldn't seem to get my first cql query for the tables complete.

As for your second query can you explain this:

!@com.Text.Story.Text.Trim().empty()

-John

shelbym 19-01-2011 10:28

Text CQL
 
Nope, because it is magic. ;-) Just kidding.

Basically I need a way to test if the paragraph text had any text in it. So:
Code:

@com.Text.Story
gets the string of text in the paragraph text shape:
Code:

.Trim()
removes any spaces or tabs before and after the string, the we test to see if anything is left with the:
Code:

.empty()
If nothing is left we are returned the boolean value of true, meaning that there is no text in the paragraph text shape. But I want the opposite of this, I want all the paragraph text shapes what are false, meaning they have some text in them so I use the Not operator the exclamation mark.
Code:

!@
-Shelby

runflacruiser 19-01-2011 13:50

Quote:

Originally Posted by shelbym (Post 18197)
Nope, because it is magic. ;-) Just kidding.

Code:

.Trim()
Code:

.empty()
-Shelby

Thanks. These look like functions because of the parentheses. Do they behave as so in the query or act as properties instead.

Also, I know we heard this question before...Any new docs on CQL?

-John

shelbym 19-01-2011 15:37

Cql
 
Since we are not passing anything, the () would be optional. You could rewrite like this:
Code:

Sub MyTableTextColorChanger()
    Dim s As Shape, sr As ShapeRange
   
    Set sr = ActivePage.Shapes.FindShapes(Query:="@type='plugin:table' and (@com.ParentGroup = null or @com.ParentGroup.Type <> 21)") 'Return just the tables
    Set sr = sr.Shapes.FindShapes(Query:="@type='text:paragraph' and !@com.Text.Story.Text.Trim.empty") 'Find all text
   
    sr.ApplyUniformFill CreateRGBColor(255, 0, 0)
End Sub

-Shelby

runflacruiser 19-01-2011 15:43

Quote:

Originally Posted by shelbym (Post 18200)
sr.ApplyUniformFill CreateRGBColor(255, 0, 0)
[/code]

-Shelby

Shrinking it even more.
I like that...I forgot I can do that to sr's

-John

shelbym 19-01-2011 17:35

Quote:

Originally Posted by runflacruiser (Post 18198)
Also, I know we heard this question before...Any new docs on CQL?

Don't forget about Alex's blog post, it is a great CQL resource.

Using Corel Query Language (CQL) to search for objects in CorelDRAW documents

-Shelby


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

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