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 18-01-2011, 17:12
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default 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
Reply With Quote
  #2  
Old 19-01-2011, 01:38
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default 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
Reply With Quote
  #3  
Old 19-01-2011, 08:39
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

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
Reply With Quote
  #4  
Old 19-01-2011, 10:28
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default 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
Reply With Quote
  #5  
Old 19-01-2011, 13:50
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by shelbym View Post
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
Reply With Quote
  #6  
Old 19-01-2011, 15:37
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default 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

Last edited by shelbym; 19-01-2011 at 15:38. Reason: pasted the wrong code
Reply With Quote
  #7  
Old 19-01-2011, 15:43
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by shelbym View Post
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
Reply With Quote
  #8  
Old 19-01-2011, 17:35
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default

Quote:
Originally Posted by runflacruiser View Post
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
Reply With Quote
Reply

Tags
cells, tables


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
Recorder not working runflacruiser Macros/Add-ons 2 19-01-2011 08:32
Working With Text shelbym Code Critique 2 12-07-2006 08:37
ConvertToCurves not working. rsriram22 CorelDRAW/Corel DESIGNER VBA 2 29-06-2006 10:40
Tables in Corel Draw 10 betob New product ideas 0 04-09-2003 05:46


All times are GMT -5. The time now is 15:10.


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