Hello,
I am trying to assign properties to multiple items (words) in Pages 4.3 (aka Pages 2009) with the following instruction:
set properties of {word 1, word 2, word 4} of last paragraph to {font name:"Menlo", font size:12, color:{32896, 0, 0}}
The whole Script:
tell application "Pages"
activate
try
set the templateNames to templates
-- prompt user to pick a template
set thisTemplateName to (choose from list templateNames with prompt "Choose a template:")
if thisTemplateName is false then
error number -128
end if
set thisTemplateName to thisTemplateName as string
-- Choose a template by dialog, create a new document and resize it
set newDoc to make new document at front with properties {template name:thisTemplateName}
set the bounds of the front window to {1, 22, 600, 596}
tell newDoc
make new paragraph at end of the body text with data "\"new word\" at \"end\" of \"body text\""
set properties of words 1 thru 2 of body text to {font name:"DaxPro", font size:12, color:{32896, 0, 0}}
set properties of word 4 of body text to {font name:"DaxPro", font size:12, color:{32896, 0, 0}}
set the color of words 6 thru 7 of last paragraph to {0, 32896, 65535}
make new paragraph at end of the body text with data "\"new bold paragraph\" at \"end\" of \"Body Text\" with data \"FOO\""
set properties of last paragraph to {font name:"DINPro", font size:14}
set properties of last word of last paragraph to {font name:"Menlo", color:{0, 32896, 65535}}
set properties of word 2 of last paragraph to {bold:true}
-- The following instruction doesn't work; even more, it prevents the next two instructions from execution
set properties of {word 1, word 2, word 4} of last paragraph to {font name:"Menlo", font size:12, color:{32896, 0, 0}}
-- These two lines are prevented from execution due to the previous command
make new paragraph at end of the body text with data "111111"
set (the last paragraph of the body text) to "\"last paragraph\" of \"Body Text\"" & return
end tell
end try
end tell
During one script execution (can’t reproduce it) AppleScript was able to realize the items to alter (words 1 thru 2, word 4) properly, as it was giving the output error:
Any ideas what might be wrong and how to apply properties to multiple items?
Cheers,
B.