Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript: Numbers

Howdy,


I'm an inexperienced wanna-be developer (n00b I believe they're called 😉 ) and I'm trying to automate some stuff at work. I have a Numbers spreadsheet I'm trying to use to keep track of some stuff and I'm trying to take some text that I've put into a variable and want to put that into a cell.


Right now, I've got this:


tell selectedTable

set the value of cell B2 to variable

end tell


Prior to this code I have a small bit that just adds a row below the header row which works great. Whenever I run the code, I don't get an error but nothing gets put into the cell I've designated.


Any help would be appreciated!

iMac (27-inch, Late 2013), OS X Yosemite (10.10.1)

Posted on Jun 23, 2015 3:20 PM

Reply
Question marked as Best reply

Posted on Jun 23, 2015 5:43 PM

set variable to "20"

tell application "Numbers"

set selectedTable to table 1 of sheet 1 of document 1

tell selectedTable

set value of cell "B2" to variable

end tell

end tell

2 replies

Jun 26, 2015 8:21 AM in response to david.lski

Note that you don't have to "hardwire" selectedTable to table 1 of sheet 1 of document 1. You might be wanting to place the variable in some other table. Numbers doesn't expose to AppleScript a "selected table" property the way it does an active sheet property. But you can easily address the currently active table (after first addressing active sheet) using this: first table whose selection range's class is range.

So your script might be something like this:

set myVariable to 20

tell application "Numbers"

tell document 1 to tell active sheet

set selectedTable to first table whose selection range's class is range

set selectedTable'scell "B2"'s value to myVariable

end tell

end tell


This will place the value in whichever table you have your cursor in.


SG

AppleScript: Numbers

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