TheTechNut wrote:
Let's say I want to have the information in Document 1, Sheet 1, Table 1, Cell A2 added to Document 2, Sheet 1, Table 1, Cell A2. I
The AppleScript could be this:
tell application "Numbers"
set srcCell to document "MyTestDoc1.numbers"'s sheet 1's table 1's cell "A2"
set tgtCell to document "MyTestDoc2.numbers"'s sheet 1's table 1's cell "A2"
set tgtCell'svalue to (tgtCell'svalue) + (srcCell'svalue)
end tell
And the JavaScript for Automation could be this:
Numbers = Application('Numbers');
var srcCell = Numbers.documents['MyTestDoc1.numbers'].sheets[0].tables[0].cells['A2'];
var tgtCell = Numbers.documents['MyTestDoc2.numbers'].sheets[0].tables[0].cells['A2'];
tgtCell.value = tgtCell.value()+srcCell.value();
In both cases you copy-paste the script into Script Editor (in Applications > Utilities) make sure Script Editor is checked at System Preferences > Security & Privacy > Privacy > Accessibility (this only needs to be done once) and also is toggled to the right scripting language, make sure both Numbers documents are open, and click the 'triangle' run button in Script Editor. If you end up with a script that you use often there are ways to have it in your menu and also attach it to a keyboard shortcut. Scripts can be an easy way to extend the functionality of Numbers, but note that they don't trigger updates automatically the way formulas do. You must trigger them yourself.
SG