In the past, I wrote some little routines that helped me in my writing with Pages 4.3, and it worked very well for me. However, I have tried numerous times to make the conversion to Pages 5.5.3, with no success. Can anyone help me with this?
The following routine works fine in Pages 5.5.3:
–======================================================================
–Script Starts Here
–para1
set para1Text to “This is the first paragraph.” & return
–para2
set para2Text to “This is the second paragraph.” & return
–para3
set para3Text to “This is the third paragraph.” & return
–para4
set para4Text to “This is the forth paragraph.” & return
tell application “Pages”
activate
#Create a new Pages document using a template "Blank," if available.
set the installedTemplates to the name of every template
if installedTemplates contains "Blank" then
set currentDocument to make new document with properties {document template:template "Blank"}
else
display dialog "Error: The Blank Template Is Not Installed."
end if
tell body text of currentDocument
-- First we create a line of text using whatever style we happen to have at this time.
set paragraph 1 to para1Text
-- Now we create a second line of text using whatever style we happen to have at this time.
set paragraph 2 to para2Text
-- Now we create a third line of text using whatever style we happen to have at this time.
set paragraph 3 to para3Text
-- Now we create a forth line of text using whatever style we happen to have at this time.
set paragraph 4 to para4Text
-- Now lets see if we can add text to the end of paragraph 2.
set paragraph 2 to paragraph 2 & " Here is an added sentence."
-- Now lets makes some changes to paragraph 3.
tell paragraph 3
set the color of it to "red"
set the size to "18"
set the font to "Helvetica"
end tell
-- So far, so good. HOWEVER:
-- Now lets makes some more changes to paragraph 3.
tell paragraph 3
--set the alignment to "center"
--set bold to "true"
end tell
-- That doesn't work, lets try something else:
-- make new paragraph style with properties {name:"ParagraphThree", font name:"Palatino", font size:24, bold:true, alignment:center}
end tell
-- That doesn't work either.
end tell
–Script Ends Here
–======================================================================
The issue comes when I try to set the alignment and font style. Take note of the code at the bottom:
tell paragraph 3
--set the alignment to "center"
--set bold to "true"
end tell
If I remove the comments, the script fails. How is one supposed to set the alignment and font style in Pages 5.5.3?
Something like this does not work either:
make new paragraph style with properties {name:“ParagraphThree”, font name:“Palatino”, font size:24, bold:true, alignment:center}
Any help is greatly appreciated.