Failed attempt to define a range using AppleScript
When setting an iWork range name using row numbers:
tell application "Numbers"
activate
tell document 1
tell sheet 1
tell table "test"
set rangename to "3:4"
set selection range to range rangename
end tell
end tell
end tell
end tell
works fine
BUT changing the statements inside the tell blocks to:
set a to "3"
set b to "4"
set rangename to "\"" & a & ":" & b & "\""
log rangename
set selection range to range rangename
—> (*"3:4"*)
set selection range of table "test" of sheet 1 of document 1 to range "\"3:4\"" of table "test" of sheet 1 of document 1
--> error "The range value cannot be retrieved." number -10000 from range "\"3:4\"" of table "test" of sheet 1 of document 1
My question is "Why does the Event Handler fail?" The log message suggests that the range name has been constructed correctly.
As shown in iworkautomation.com/numbers/ there is another way to construct rangename :
set rangename to ((name of first cell of row a) & ":" & (name of last cell of row b))
but I’m wondering about the reason the previous attempt failed as I suspect it might illuminate a gap in my understanding of AppleScript.
MacBook Pro 15″, macOS 10.14