The first limitation of the script is that the fonts
need to be named exactly. Make sure you are spelling
the font right: exactly as it is in the error message.
As far as I can see I have spelled it exactly as it
is in the errror message.
That's not necessarily the font name. It's just the 'display name'.
Here's a script that will list all the font names in the front document, let you choose one, and then copy it to the clipboard so you can paste it into my earlier script.
<pre>
tell application "Pages"
tell front document
-- Find all the fonts in the document.
set distinctFonts to {}
set manyFonts to font name of every word of body text
repeat with aFont in manyFonts
set foundFont to false
if distinctFonts contains aFont then set foundFont to true
if foundFont is false then set distinctFonts to distinctFonts & aFont
end repeat
-- Ask the user to choose one font.
set fontToReplace to (choose from list distinctFonts ¬
with title ¬
"Choose a font" with prompt ¬
"This is the font which will be replaced in the front Pages document." default items ¬
{item 1 of distinctFonts} ¬
multiple selections allowed false ¬
without empty selection allowed)
-- Copy name of selected font to the clipboard, activate Pages, and tell the user we're done.
if fontToReplace is not false then
set the clipboard to fontToReplace as string
display dialog "The font name has been copied to the clipboard so you can paste it into a script."
tell application "Pages" to activate
end if
end tell
end tell
</pre>
I'd be curious to learn if this helps.
Dale