Hello, good evening, awesome.
First of all, much thanks and beers to the contributors in http://bbs.macscripter.net/viewtopic.php?id=13008.
It’s old, yeah, but it told me everything I had been clawing my eyes out over trying to make work for a solid day and a half. Having not programmed anything in well over 2 years now, and never having heard of Applescript before a few weeks ago, things have been a little confusing, but this site has helped far more than the Adobe forums ever have for anything.
Well, almost everything, because now that I’ve found a way to tear through lots of files changing multiple-word sets to other multiple-word sets, I want to change the attributes of those multiple-word sets.
So where I’m at now is looking at a slightly modified version of the example code in the Illustrator CS3 Applescript Reference that tells you a simple way of searching for a word and changing it’s colour. It’s not exactly what I want to do, but my problem is nearly identical to this, only in the script I’m writing I’ve got a few more loops and variables set that aren’t pertinent to the problem.
set searchString to "Many words" as Unicode text
tell application "Adobe Illustrator"
set textArtItemCount to (count text frames in document 1)
if (textArtItemCount > 0) then
repeat with itemCounter from 1 to textArtItemCount
if (((contents of text frame itemCounter of document 1) as Unicode text) contains searchString) then
set the text font of (words of text frame itemCounter of document 1 whose contents = searchString) to "Interstate-Regular"
end if
end repeat
end if
end tell
The error I get tells me that it can’t do what the instruction to change the fill colour is telling it to do, and that line is highlighted.
Now this code works if searchString is a single word, but logically something feels wrong with that line I’m getting the error on. I just don’t have nearly enough experience to figure out exactly what it is. I’m also still wrapping my head around delimiters, but from what I do know I don’t think they would help a lot in this case.
If anyone can explain to me what’s going wrong, they’d be much appreciated.
Model: PowerPC G5
AppleScript: 1.10.7
Browser: Firefox 2.0.0.14
Operating System: Mac OS X (10.4)