I am using AppleScript to write ticket numbers in a pages document. It has worked great for years. But this set of tickets I would like to have the text colour be white instead of black. I cannot find a way to change the colour. Any idea’s?
This is the line that inserts the text. It is in a text box so Changing the body text does not seem to do anything.
make new text item with properties {width:textboxWidth, height:textboxHeight, position:{thisHorizontalOffset + firstTextboxHorzOffset, thisVerticalOffset + firstTextboxVertOffset}, object text:ticketNumber}
I’m not very knowledgeable with the Pages app but apparently you have to create the text item and then set the properties of the text in the text item. The following script demonstrates this–a blank page in the Pages app has to be open before running this script.
set theText to "This is a test"
tell application "Pages"
activate
tell document 1
set locked of every iWork item to false -- just for testing
delete every iWork item -- just for testing
tell current page
set theTextItem to make new text item with properties {height:400, width:400, position:{72, 72}, object text:theText}
tell object text of theTextItem to set properties to {font:"Helvetica", size:25, color:{0, 0, 65535}} -- blue color
end tell
end tell
end tell
To test the example you need to have text object already.
tell application "Pages"
set theDoc to front document
tell text item 1 of current page of theDoc
set object text to "macscripter.net" & return & "AppleScript" & return & "Apple" & return & "macOS Ventura"
-- all text become green
set color of object text to {0, 65000, 0}
-- first paragraph become red
set color of paragraph 1 of object text to {65000, 0, 0}
-- first word of last paragraph become blue
set color of first word of last paragraph of object text to {0, 0, 65000}
end tell
end tell