change background color of text in text edit

How can I highlight text with changing the background color in Textedit using applescript. I’ve found this script but it only changes the text color, not the background color.

activate application "TextEdit"
tell application "System Events" to tell text area 1 of scroll area 1 of window 1 of process "TextEdit" to if exists then
	set {x, y} to value of attribute "AXSelectedTextRange"
	if x ≤ y then tell application "TextEdit" to set color of document 1's characters x thru y to {65535, 6196, 10546}
end if

Happy xmas!

Hi,

I guess you can’t.
In the color palette you can set the document background color globally but not for a selected range of text.
The AppleScript dictionary contains only the property to set the text color

As far as I know, the background color is not reachable/settable thru AppleScript.

Try to use a third party editor like Text-Edit.

Yvan KOENIG (VALLAURIS, France) jeudi 25 décembre 2014 16:47:22