Indesign CS3 Find Replace fill color

Hello,

I am absolutely stuck with this simple script. I want to find all prices in a document that are red and remove them. I got it working in CS2 but CS3 wont play ball… Here’s the script:

property SALE_RED : “C=20 M=100 Y=100 K=10”

tell application “Adobe InDesign CS3”
set this_doc to document 1

set find text preferences to nothing
set change text preferences to nothing
set fill color of find text preferences to SALE_RED

set properties of find text preferences to {find what:"£^9^9^9.^9^9"}
set properties of change text preferences to {change to:""}
tell this_doc to change text

end tell

As you pobably guessed, I have a colour named “C=20 M=100 Y=100 K=10” in the swatches pallette.

I can get a handle on the field with:
set test to fill color of find text preferences
but if I attampt to change it with:
set fill color of find text preferences to “C=20 M=100 Y=100 K=10”

… it says “expected string, swatch or nothing”

Please Help!! :slight_smile:
Daz

Model: G5 10.4
AppleScript: 4
Browser: Firefox 3.5.3
Operating System: Mac OS X (10.4)

See this thread for an explanation: http://macscripter.net/viewtopic.php?id=29804

Based off of this experience you could be able to do something like this:

tell application "Adobe InDesign CS3"
	activate
	tell document 1
		set findSwatch to swatch "C=20 M=100 Y=100 K=10"
		delete (every word of every story whose fill color is findSwatch and contents contains "£" and contents contains ".")
	end tell
end tell

Since the word must contain the pound symbol and a period it should eliminate any other “words” that might have that color applied.

Hi Jerome,

Thanks for your reply, it works great for text in text box’s but unfortunately in does not work with text in tables. It seems such a shame I cant set the find text preference to the fill color like I have done with CS2, CS3 just wont let me do it.

Any more suggestions?? :slight_smile:

  • Thanks!

Yea, it kind of makes the find/change useless with colors if you can’t use document level colors. It should be possible to target the text in tables in a similar fashion that you do the stories, I will have to look at the syntax to see how to do it.

Reworking the delete statement to address the contents of a table cell gives us the following:

tell application "Adobe InDesign CS3"
	set x to selection
	tell document 1
		set x to count of tables of story 1
		set findSwatch to swatch "C=20 M=100 Y=100 K=10"
		delete (every word of every cell of every table of every story whose fill color is findSwatch and contents contains "£" and contents contains ".")
	end tell
end tell