my activateGUIscripting()
tell application "Numbers"
tell document 1 to tell sheet 1 to tell table 1
set value of cell "D2" to "6453"
my shortcut("Numbers", "c", "c")
set selection range to range "D2:D45"
delay 0.2
my shortcut("Numbers", "v", "c")
end tell
end tell
--=====
on activateGUIscripting()
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
end tell
end activateGUIscripting
--=====
(*
==== Uses GUIscripting ====
*)
on shortcut(a, t, d)
local k
tell application a to activate
tell application "System Events" to tell application process a
repeat with k in t
if d is "c" then
keystroke (k as text) using {command down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"sc", "cs"} then
keystroke (k as text) using {command down, shift down}
else if d is in {"kc", "ck"} then
keystroke (k as text) using {command down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
keystroke (k as text) using {command down, shift down, control down}
end if
end repeat
end tell
end shortcut
--=====
I don't understand why it doesn't do the wanted job.
Your own code will behave faster if the target table is not displayed.
I often use this trick.
Yvan KOENIG (VALLAURIS, France) mercredi 25 novembre 2009 20:23:18