Apply character style in Illustrator

Hi

I have written a script to find a bracket and apply a character style to lift the baseline by .5pt.

Does anyone know why I get this error:

error "Adobe Illustrator got an error: File/Folder expected" number 1230

with this code:

tell application "Adobe Illustrator"
	set thisDoc to current document
	tell thisDoc
		set frameCount to count every text frame
		repeat with i from 1 to frameCount
			set theText to contents of text frame i as string
			set charCount to count every character of theText
			repeat with j from 1 to charCount
				set char to character j of theText
				log char
				if char is equal to "(" then
					apply character style character style "lift bracket" to character j -- must make character style in Illustrator
				end if
				log char
				
			end repeat
		end repeat
	end tell
end tell


The script requires a character style to be made already, which I have done
I’m using Illustrator CS5.1.

Thanks in advance

Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)

hi,

I guess your reference to the character is wrong:

	apply character style character style "test" of document 1 to character 7 of document 1

… won’t work,

try with those few changes:

tell application "Adobe Illustrator"
	set thisDoc to current document
	tell thisDoc
		set frameCount to count every text frame
		repeat with i from 1 to frameCount
			set theText to characters of text frame i as string
			set charCount to count of theText
			repeat with j from 1 to charCount
				set char to item j of theText
				log char
				if contents of char is equal to "(" then
					apply character style character style "test" to char -- must make character style in Illustrator
				end if
				log char
				
			end repeat
		end repeat
	end tell
end tell

Hope it’ll work …

Bingo!

Thanks for that Hans! Much appreciated.