Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

set fill color of all words in list

New Here ,
May 28, 2010 May 28, 2010

I want to change the fill color of all words in a document from a provided list of terms.

For example, the following script works perfectly in Quark:

set theIndexList to {"3rd Class", "4th class", "4th Class", "5th class", "5th Class", "7 lines of management/defense", "7 lines of management/defense", "7 Lines Of Management/Defense", "abalakov anchor", "Abalakov anchor", "Abalakov Anchor", "adze", "Adze", "Adze", "alpine rock", "Alpine rock", "Alpine Rock", "anchor", "Anchor", "Anchor"}

tell application "QuarkXPressâ„¢ 4.11"
     tell document 1
         tell story 1
             repeat with currentWord in theIndexList
                 try
                     set (the color of every text where it is currentWord) to "Green"
                 end try
             end repeat
         end tell
     end tell
end tell

The purpose of this script is to highlight words for later indexing. I need to read through the document, see words someone else has chosen for indexing, then add them selectively to the index.

InDesign CS, Mac OSX 10.3.9

TOPICS
Scripting
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 28, 2010 May 28, 2010

you may want to try a grep style on Basic Paragraph style for these words, and that would allow you to turn on and off at will

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2010 May 28, 2010

I'm not clear on GREP style find/replace, because it doesn't appear to be a feature of InDesign CS(1), which my client specifically requested I use (don't ask why).

I want a script to use in InDesign CS(1) that will do exactly what the sample Quark script does. I posted this question because I'm not clear why the same script -- modified for InDesign CS(1), of course -- doesn't work. I get this error, which I appologize for not posting earlier:

InDesign CS got an error: Can't set fill color of every text of story 1 of document 1 whose it = item 1 of {"3rd Class", "4th class", "4th Class", "5th class", "5th Class", "7 lines of management/defense", "7 lines of management/defense", "7 Lines Of Management/Defense", "abalakov anchor", "Abalakov anchor", "Abalakov Anchor", "adze", "Adze", "Adze", "alpine rock", "Alpine rock", "Alpine Rock", "anchor", "Anchor", "Anchor"} to "Red".

To clarify the issue: My client decided after the fact that they wanted an index in this hundred-page document. They supplied a list of terms for me to include in the index, so I needed a way to see each term in the document without having to read it line-by-line.

Can anyone make the sample Quark script work in InDesignCS(1)?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 28, 2010 May 28, 2010

I have not idea about applescript but here is javascript code if you want use.

var findForIndex = ["3rd Class", "4th class", "4th Class", "5th class", "5th Class", "7 lines of management/defense", "7 lines of management/defense", "7 Lines Of Management/Defense", "abalakov anchor", "Abalakov anchor", "Abalakov Anchor", "adze", "Adze", "Adze", "alpine rock", "Alpine rock", "Alpine Rock", "anchor", "Anchor", "Anchor"]
for (a=0; a<findForIndex.length; a++)
{
app.changePreferences = NothingEnum.nothing;
app.findPreferences = NothingEnum.nothing;
app.changePreferences.fillColor = app.activeDocument.colors.item("Green");
app.activeDocument.search(findForIndex, undefined, undefined,"");
app.changePreferences = NothingEnum.nothing;
app.findPreferences = Nothing...

Hope it will help you.

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 28, 2010 May 28, 2010

I suspect you're going to have trouble finding someone still running CS to be able to answer your question without guessing. In recent versions you would use something like Shonkyin's code (although I'm not sure his color code is correct -- he's using a reference to a document color for change text preferences), but it was quite different in CS.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 28, 2010 May 28, 2010

I have tested my code before posting here in CS and its working.

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 28, 2010 May 28, 2010

My apologies, Shonkyin! I mis-remembered when the changes were made.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2010 Jun 05, 2010

Thank you, Shonky, for the JavaScript. It did exactly what I needed the

AppleScript to do.

I remain curious as to why InDesign CS(1) can't use the AppleScript in

question. I have tried the AppleScript on InDesign CS3, and it does not

work there either.

Thanks again,

Tim

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 06, 2010 Jun 06, 2010

> I remain curious as to why InDesign CS(1) can't use the AppleScript in question.

It was written for QuarkXPress; InDesign has a different (and more complex) object model.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2010 Jun 06, 2010

It's not a question of which program has more complex object model.

It's a matter of being able to solve a problem in the most

straightforward way possible with the tools available. It's certainly

not a Quark vs InDesign issue. They both have their merits and

drawbacks.

In the case of this script, Quark allowed me to solve my problem more

quickly, but to InDesign's credit, JavaScript was available to solve

the problem.

Because this is an AppleScript forum, I'll leave off with this request:

if anyone wants to write an AppleScript to solve this problem, I'd be

really interested to see it.

--

>> I remain curious as to why InDesign CS(1) can't use the AppleScript

>> in question.

 

It was written for QuarkXPress; InDesign has a different (and more

complex) object model.

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 06, 2010 Jun 06, 2010

>It's not a question of which program has more complex object model

Actually, it is largely. Search and replace in Quark relied on a combination of AppleScript whose clauses and a slightly odd definition of its text class. This made searches very simple, but it also meant they were restricted in what they could do. InDesign uses a more complex model, and exposes the full find/change engine; it's not as straight-forward, but it lets you do things that wouldn't be possible if they stuck to the whose clause approach.

In fact you can use whose clauses similarly in InDesign, with one catch: InDesign has a different definition of what constitutes text (there is only 1 text per story), so it will only work if you're looking for one of the classes like words, lines, text style ranges, etc.

I hesitate to rewrite the the js version in AS for CS because I don't have CS installed here. And there's an oddity involving color searches that makes it a bit more complicated than it should be. But it's very similar to the javascript.

> Because this is an AppleScript forum

I'm not sure what gave that impression, but it's far from so.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2010 Jun 06, 2010
LATEST

lllllllllllllllllllllllllllllllllllllllllllllllhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines