select cells numbers with applescript
Hi!
How can select the cells A1 A16 A31 A46 A61 with applescript?
And how can change the background of these cells with an image with applescript?
Thanks!
iMac, macOS Sierra (10.12.6), null
Apple Event: May 7th at 7 am PT
Hi!
How can select the cells A1 A16 A31 A46 A61 with applescript?
And how can change the background of these cells with an image with applescript?
Thanks!
iMac, macOS Sierra (10.12.6), null
If you can copy that one image to the system clipboard (I did that by opening the image in Preview and choosing Edit > Copy from the menu) then the script below should do what you want.
Just add additional cell names to the list as needed.
SG
-- copy image to system clipboard before running
set tgtCellNames to {"A1", "A16", "A31", "A46", "A61"}
repeat with aName in tgtCellNames
pasteImgToCell(aName)
end repeat
to pasteImgToCell(cellName)
tell application "Numbers"
tell the first table of the active sheet of document 1
set selection range to cellcellName
activate
tell application "System Events" to keystroke "v" using command down
end tell
end tell
end pasteImgToCell
If you can copy that one image to the system clipboard (I did that by opening the image in Preview and choosing Edit > Copy from the menu) then the script below should do what you want.
Just add additional cell names to the list as needed.
SG
-- copy image to system clipboard before running
set tgtCellNames to {"A1", "A16", "A31", "A46", "A61"}
repeat with aName in tgtCellNames
pasteImgToCell(aName)
end repeat
to pasteImgToCell(cellName)
tell application "Numbers"
tell the first table of the active sheet of document 1
set selection range to cellcellName
activate
tell application "System Events" to keystroke "v" using command down
end tell
end tell
end pasteImgToCell
It's easy to select cells with AppleScript but one needs to know the document, sheet, and table.
As for setting the background, that can't be done with AppleScript, though it might be possible to paste an image in.
Perhaps you could give more details of what you are trying to do, and why you need to do it using a script.
SG
Thanks SGIII !!!
I use this script to color the cells A1 A16 A31 A46 A61:
on run {input, parameters}
tell application "Numbers"
activate
tell the first table of the active sheet of document 1
set the background color of cell "A1" to {65535, 0, 0}
set the background color of cell "A16" to {65535, 0, 0}
set the background color of cell "A31" to {65535, 0, 0}
set the background color of cell "A46" to {65535, 0, 0}
set the background color of cell "A61" to {65535, 0, 0}
end tell
end tell
return input end run
I need to insert a background image in these cells.
If it isn't possible I thought to select the cells A1 A16 A31 A46 A61 with applescript and then change manually the background.
P.S. Actually the cells are many more, for this I need to use applescript.
Is it one background image for all those cells, or is it a different background image for each cell?
SG
one background image for all
Thanks!!!
Thanks a lot, SGIII !!!
select cells numbers with applescript