I have a quark file. In this quark file, I have number of words with a character style “KT” applied to it.
I want to replace the word whose character style is “KT” to some “xxxxx”
I am able to get the reference to all words but unable to replace them.
My script is:
tell document 1 of application "QuarkXPress"
tell text box 1 of page 1
set para to (a reference to (every word whose character style is equal to "KT")) as list
-- Here I want to replace the text
end tell
end tell
Getting the reference to every word (whose something is whatever) gets the word itself, but doesn’t say where those words are in the story, which Quark needs to know in order to replace them with another word. If the word can be anything and the criteria is to replace any word with the style “KT” applied to it then this might work (example story content of “This word has style, the rest don’t” where “word” and “style” have character style “KT” applied):
tell document 1 of application "QuarkXPress"
tell story 1 of text box 1 of page 1
--set para to (a reference to (every word whose character style is equal to "KT")) as list --{"word", "style"}
set wordIndexes to (index of (every word whose character style is equal to "KT")) as list --{2, 4}
repeat with thisIndex in wordIndexes
set word thisIndex to "xxxxx"
end repeat
end tell
end tell