Change style sheet based on x,y of text box - Quark

I need to change the style sheet of a text box within a Quark doc.
I can get this to work:


try
  tell text box 10
	set style sheet of paragraph 1 to "newStyleSheet"
end tell
						
end try

But I would rather find the location than by the text box number.

I’ve been trying this, but can’t get it to work:


try
  if exists (left of bounds of text box) as real is 98.875 then -- y-axis
   if exists (top of bounds of text box) as real is 67.5 then -- x-axis
	set style sheet of paragraph 1 to "newStyleSheet"
 end if
end if
						
end try

These have not been tested, I just typed them in here, but are the directions that I would use to try to solve your dilemma.

set theBounds to bounds of text box 10
if item 1 of theBounds is 98.875 and item 2 of theBounds is 67.5 then --x and y might be switched here
    set style sheet of paragraph 1 of text box 10 to "newStyleSheet"
end if

If you are testing a document you might try something like this:

try
set theTextBoxes to object reference of every text box whose (left of bounds as real) is 98.875 and whose (top of bounds as real) is 67.5
repeat with aTextBox in theTextBoxes
    set style sheet of paragraph 1 of aTextBox to "newStyleSheet"
end repeat
end try

If that does not work step through them page by page and text box by text box.

Thank you Jerome.
First I tried to get the bounds of the text box and it returned a really long string of numbers “«data FRMS00620000005C00000175000001AB0000»”
I can then use that value to set the style sheet to the text box with those bounds. Would there be any issue using this long value in a script? It seems to work. I guess that’s what script is about :slight_smile:

~N