I am trying to use Numbers within a script to print characters of a name into preprinted boxes on a preprinted form. All the characters align centrally within each box apart from the letter ‘I’ which always appears left justified. Is there a way to centrally align characters within a text box, have looked at the Numbers dictionary but cannot find a reference. Any guidance gratefully received!
set textItem to make new text item with properties {object text:item 1 of theChars, position:{81, 565}}
tell textItem to tell its object text to set properties to {font:Eurostile, size:12}|
Tahoe 26.3.1 Numbers 14.5 Xcode 26.3
I see no method other than CLICK at LOCATION that would allow you to set the alignment of text box contents. Instead, Select your text box. Choose ( From the Window’s GUI ) [ Format / Text / (center alignment icon ) ]Then SELECT ( from the Menu Bar ) [ Format / Advanced / Set as default Text Box Appearance ]
This will center align all your future text box contents until you change the [ Set as default Text Box Appearance ] option. This works here on Sequoia 15.5 (24F74)
tell application "Numbers"
tell document 1
tell sheet 1
set theChars to "Index"
set textItem to make new text item with properties {object text:item 1 of theChars, position:{81, 565}, height:60, width:100}
tell textItem to tell its object text to set properties to {font:"Lucida Grande", size:12}
end tell
end tell
end tell
Thanks for your reply, I will start experimenting!
I have just discovered monospaced fonts which means that all characters take the same space, I thought all fonts were proportional so problem now solved.
Thanks to everyone who took the time to read my post.