[IDCS3] Need help on Find/Change with customized color

I am trying to do a global change of text color from the default [Black] to customized color, eg. Red. My script is as follows:-

tell application "Adobe InDesign CS3"
	activate
	
	set find text preferences to nothing
	set change text preferences to nothing
	
	set find what of find text preferences to "^?"
	set properties of find text preferences to {fill color:"Black"}
	--set properties of change text preferences to {fill color:"Black", fill tint:50} --this line WORKS
	set properties of change text preferences to {fill color:"Red", fill tint:50} --this line fill color DOESN'T WORKS but fill tint WORKS!
	
	tell document 1
		change text
	end tell
	
	--set find text preferences to nothing
	--set change text preferences to nothing
	
end tell

However, the "fill color:“Red” does not have any effect at all (but the fill tint:50 has). I then try command+F on the ID file and find that the “change format” does not accept the customized color name.

Could anyone help me to see whether I have missed out anything?

Tks!

From playing around with it I’m pretty sure the problem is that the find prefs are a property of the application not the document. The red swatch is part of the document so the find pref cannot be set to it. You might try adding the swatch to your default swatch list or do the change at the document level, something like this should work:

tell application "Adobe InDesign CS3"
	activate
	tell document 1
		set changeSwatch to swatch "Red"
		set findSwatch to swatch "Black"
		set properties of every word of every story whose fill color is findSwatch to {fill color:changeSwatch, fill tint:25}
	end tell
end tell

Change the “word” to characters would take longer but be more precise, as it is structured above it will not change characters in a word that are black but the rest of the word is another color. Another strategy is to get a list from the find/change and step through that. To do this change the “change text” line to "set foundText to:

tell application "Adobe InDesign CS3"
	set foundText to find text
	repeat with someText in foundText
		set properties of someText to {fill color:changeSwatch, fill tint:25}
	end repeat
end tell

Thank you, Jerome. You are right, the find text preferences is the property of application instead of document. Wonder why Adobe want to change this as it is property of document in CS2…

I adopt your first approach and it works fine.

Thanks again!