Applescript Keynote Selection Range

This script fails with "Can’t make \"A5:D5\" into type range." 

activate application "Keynote"

tell application "Keynote"

tell the front document

tell the current slide

set auction to make new table

tell auction

set selection range to "A5:D5"

tell application "System Events"

tell application process "Keynote"

click menu item "Merge Cells" of menu "Table" of menu item "Table" of menu "Format" of menu bar item "Format" of menu bar 1

end tell

end tell

end tell

end tell

end tell

end tell

A command to merge a range of cells directly without UI scripting fails, so I tried this.

Posted on Mar 27, 2021 7:02 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 29, 2021 2:15 PM

You're trying to set a range to a string. Can't do that.


				set selection range to "A5:D5"


Instead you need to be more explicit and coerce your string to a range first:


				set selection range to range "A5:D5"

Similar questions

3 replies

Mar 29, 2021 2:19 PM in response to Camelot

Digging in a little deeper:


> A command to merge a range of cells directly without UI scripting fails, so I tried this


This is still doomed to failure as is, because these cells cannot be merged - either manually or via scripting.


That's because the default table style includes one header row and one header column. Header cells cannot be merged with 'regular' cells.


To merge these cells you have to nix the header column so that all the cells are of the same class. Try:


			tell auction
				set header column count to 0
				merge range "A5:D5"



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript Keynote Selection Range

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.