I don’t seem to be able to clear character overrides when applying a paragraph style with a script to a CS3 document. I’ve tried it a number of ways, following the dictionary closely but no luck. It just doesn’t seem to clear character overrides. Does anyone know if this is a bug? What follows is the section of my script with the clear/apply in it.
What happens is this:
The script places a new anchored text box at the end of a line of text. That line has a paragraph style applied to it and a nested style that uses a character style for the first word and then the unaltered applied paragraph style for the rest of the line. The anchor mark is immediately before the hard return at the end of that line. What happens is that the text in the anchored text box is carrying over the character style from the paragraph it’s anchored in. Note that the character style is otherwise only affecting the first word in this paragraph, so it doesn’t seem like it should carry over. Once the anchored text box is created, it gets an applied object style and its text contents get an applied paragraph style. However, neither of those two actions can clear the character style. Here’s the code snippet:
--place New Style Box APPLIES TO NEW STYLES ONLY
if text of item 12 of Rev_Style_List ≠"" then -- if it's a NEW PRODUCT
set myInsertionPoint to insertion point -2
tell myInsertionPoint
set myGraphicFrame to make rectangle with properties {content type:text type, contents:"", geometric bounds:{114.48, 546.768, 128.88, 573.768}}
tell myGraphicFrame
set contents of insertion point -1 to ("NEW STYLE")
set theParagraph to the object reference of last paragraph
set theParagraphStyle to NewColorStyleBox
tell theParagraph
clear overrides overrides to clear all
apply paragraph style using theParagraphStyle
end tell
apply object style using NewStyleBox
end tell
end tell
end if