AppleScript Numbers: Get formula from cell (as modifiable text)
Environment:
- Mojave MacOS 10.14.5
- Numbers 6.1 (6369)
- Automator 2.9 (444.42)
- Both Numbers and Automator are set via System Preferences > Security & Privacy > Accessibility
Background:
From another posting I was able to create an AppleScript Service for Numbers that copies the content of the cell immediately to the left of the current cell into the current cell
Sample Table:
Sample Code:
on run {input, parameters}
tell application "Numbers"
tell table 1 of active sheet of front document
set firstCell to the first cell of the selection range
set sourceCell to value of firstCell's row's cell ((firstCell's column's address) - 1)
set value of cell "E10" to sourceCell
end tell
end tell
return input
end run
Issue:
The next piece of the puzzle is how to get, modify, and then paste the formula from the cell immediately to the left of the current cell into the current cell.
I've seen a number of examples for setting formulas in cells, but I haven't been able to find anything that [clearly, to me] shows how to retrieve a formual from a cell with AppleScript.
As near as I can tell, cells do not have a 'formula' property, only 'column', 'name', 'row', and 'value' - the last of which only seems (through my trials) to copy the resulting value of the formula, not the formula itself.
Can someone shed some light (for me) on how one can retrieve the formula from a specified cell, as text (so I can modify it) with AppleScript?
MacBook Air 13", macOS 10.14