My macro runs ok on one computer, but on another one (Corel X6 on both) gives an error at the following line:
ActivePage.Shapes.FindShapes(Query:="@type ='text:artistic' and @colors.find(cmyk(0,0,0,100)) and @right > {" & dblX & " in} and @left < { " & dblX2 & " in} and @top > {" & dblY & " in} and @bottom < { " & dblY2 & " in}").Move 0, cd * 10 / 25.4
How cant it run flawlessly on one computer and give an error on another ?
What should I modify?
Thank you.
try to break a long query into several short ones. For example,
Set srText = ActivePage.Shapes.FindShapes(Query:="@type ='text:artistic' and @colors.find(cmyk(0,0,0,100)))
Set srOtherShapes = srText.Shapes.FindShapes(Query:= ...
srOtherShapes.Move ...
Perhaps this will indicate where exactly the error occurs
I'll try.
thank you!
If I am having trouble with a CQL query - especially when I am using variables in it - then I often find it useful when troubleshooting to see exactly what string is being built for the query. "Show me exactly what CQL is trying to interpret".
For example, I might put this in right before that line in the code to display the string:
msgbox "@type ='text:artistic' and @colors.find(cmyk(0,0,0,100)) and @right > {" & dblX & " in} and @left < { " & dblX2 & " in} and @top > {" & dblY & " in} and @bottom < { " & dblY2 & " in}"
That could also be checked using Debug.Print.
I also find that it is often more convenient for me to work in document units, and to not need to use explicit units in the query. So, instead of @left, I might use @com.LeftX - and then be able to compare directly to dblX2, without having to include the curly brackets and the "in".
Doing it that way, your query string would become:
"@type ='text:artistic' and @colors.find(cmyk(0,0,0,100)) and @com.RightX > " & dblX & " and @com.LeftX < " & dblX2 & " and @com.TopY > " & dblY & " and @com.BottomY < " & dblY2
In my (limited) experience, that has also solved some problems that I have encountered when using CQL where negative numbers are involved.
I just have to take care to make sure that any values I supply - for example, from a userform - are in document units.
still not working with CQL
I have solved it by splitting it into multiple if... then sentences