script search for text in table

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
Nuetel
Posts: 0
Joined: 19 Feb 2014, 11:50

script search for text in table

Post by Nuetel » 19 Feb 2014, 05:58

Use the following script. It does not find text in tables, how can I do to find text in all tables?
How do I search and insert tab and return?
Thanks to all and sorry for my english
tell application "QuarkXPress"
set t to count documents
repeat with i from 1 to t
try
tell document 1 of application "QuarkXPress"
set (every text of every story where it is "cat ") to "dog "
set (every text of every story where it is "red") to "blue"
end tell
end try
save document 1
close document 1
end repeat
end tell

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

script search for text in table

Post by Emma » 19 Feb 2014, 06:04

I haven't got Quark handy, so I can't help with the tables. But I can see one immediate problem:

All of your repeat addresses 'document 1'. You need to change this to 'document i' every time it appears (otherwise it will just search document 1, i times!)

Tab and return are called simply that - e.g. 'set word 1 to word 1 & tab & return'

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

script search for text in table

Post by Jean-Marie Schwartz » 19 Feb 2014, 21:07

Sorry Emma, you're wrong. Since the OP closes document 1 all the time, the tell document 1 instruction always addresses the right document. Are you with me?

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

script search for text in table

Post by Emma » 19 Feb 2014, 21:38

Oops. Hadn't noticed that. Sorry!

Nuetel
Posts: 0
Joined: 19 Feb 2014, 11:50

script search for text in table

Post by Nuetel » 19 Feb 2014, 22:22

Thanks for the replies.
I tried to change the script, but it does not work...
tell application "QuarkXPress"
set t to count documents
repeat with i from 1 to t
try
tell document 1 of application "QuarkXPress"
set (every text of every story where it is "cat") to "dog"
set (every text cell of every table box where it is "red") to "blue"
end tell
end try
save document 1
close document 1
end repeat
end tell

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

script search for text in table

Post by Jean-Marie Schwartz » 19 Feb 2014, 22:34

Hi Nuetel! I almost never work with cells and tables so I had to play a lot with it to end with sth that works.
Here is the solution: just add this line below the others
set (every text of story 1 of every table boxwhere it is "cat") to "dog"
May I draw your attention on one point: if you're targetting text instead of word then any occurrence of "cat" even inside of a whole word shall be changed into "dog", so "catwoman" shall become "dogwoman". Don't know if you were aware of that. Maybe that's what you want. Maybe not. HTH.

Nuetel
Posts: 0
Joined: 19 Feb 2014, 11:50

script search for text in table

Post by Nuetel » 20 Feb 2014, 03:59

Thanks Jean-Marie Schwartz !!
but the scriptdoes not find anything with
set (every text of story 1 of every table boxwhere it is "cat") to "dog"

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

script search for text in table

Post by Jean-Marie Schwartz » 20 Feb 2014, 04:34

What? Can you post the entire code please? (Unless it is down to v8 and your environment?)

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

script search for text in table

Post by Jean-Marie Schwartz » 20 Feb 2014, 04:46

Ooops! Sorry I had to replace your line tell document 1 of application "QuarkXPress" with tell document 1 (since the line is already wrapped into a tell application block). Let me know if it works.
Also I can't seem to have a case sensitive S&R, sorry.

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

script search for text in table

Post by Emma » 20 Feb 2014, 05:03

If you wrap it in a
considering case
...
end considering
will that make it case sensitive?

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”