• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Identity a hidden column in Numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Identity a hidden column in Numbers


  • Subject: Identity a hidden column in Numbers
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 25 May 2010 16:51:20 +0200

Hello

I'm working on a script in which I need to know if a column of a table of a sheet of a Numbers document is hidden.

Alas, there is no provision to get this property in the AppleScript dictionary.

I built a handler which gives the info but it's a bit annoying : it send a beep when it is applied to a hidden column.
Here it is :


--[SCRIPT]
--=====

my isItHidden(1, 1, 1, 2)

--=====

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 isItHidden(d_Name, s_Name, t_Name, col_num)
tell application "Numbers"
set d_Name to name of document d_Name (* useful if d_name was a number *)
tell document d_Name
set s_Name to name of sheet s_Name (* useful if s_name was a number *)
tell sheet s_Name
set t_Name to name of table t_Name (* useful if t_name was a number *)
tell table t_Name
set aCell to (first cell of column col_num)
set val1 to value of aCell
set selection range to aCell
end tell -- table
end tell -- sheet
end tell -- document
end tell -- Numbers
--log "val1 = " & val1
(*
I guess that the built string will not be the value stored in the cell ;-)
*)
set maybe to (current date) as text
set the clipboard to maybe & (reverse of text items of maybe) as text
my raccourci("Numbers", "v", "c") (* Paste.
Will beep if the column is hidden but doesn't issue an error ! *)
tell application "Numbers" to tell document d_Name to tell sheet s_Name to tell table t_Name
repeat 2 times
set val2 to value of aCell (* a kind of temporization matching the processor power *)
end repeat
--log "val2 = " & val2
set value of aCell to val1
end tell -- Numbers
return (val1 = val2) (* TRUE if the column is hidden *)
end isItHidden


--=====
(*
==== Uses GUIscripting ====
*)
(*
This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
It may be used to 'type' keyboard shortcuts if the third parameter describe the required modifier keys.
*)
on raccourci(a, t, d)
local k
tell application a to activate
tell application "System Events" to tell application process a
set frontmost to true
try
t * 1
if d is "" then
key code t
else if d is "c" then
key code t using {command down}
else if d is "a" then
key code t using {option down}
else if d is "k" then
key code t using {control down}
else if d is "s" then
key code t using {shift down}
else if d is in {"ac", "ca"} then
key code t using {command down, option down}
else if d is in {"as", "sa"} then
key code t using {shift down, option down}
else if d is in {"sc", "cs"} then
key code t using {command down, shift down}
else if d is in {"kc", "ck"} then
key code t using {command down, control down}
else if d is in {"ks", "sk"} then
key code t using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
key code t using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
key code t using {command down, shift down, option down}
end if
on error
repeat with k in t
if d is "" then
keystroke (k as text)
else if d is "c" then
keystroke (k as text) using {command down}
else if d is "a" then
keystroke k using {option down}
else if d is "k" then
keystroke (k as text) using {control down}
else if d is "s" then
keystroke k using {shift down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"as", "sa"} then
keystroke (k as text) using {shift 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 is in {"ks", "sk"} then
keystroke (k as text) using {shift 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}
else if (d contains "c") and (d contains "s") and d contains "a" then
keystroke (k as text) using {command down, shift down, option down}
end if
end repeat
end try
end tell
end raccourci


--=====
--[/SCRIPT]

I hope that somebody will be able to find a better scheme.
I must add that I know that the code may replace a formula by its value but itsn't a problem here.


Thanks in advance.

Yvan KOENIG (VALLAURIS, France) mardi 25 mai 2010 16:51:17



_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Identity a hidden column in Numbers
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: Re: [ann] Learn AppleScript, 3rd edition now available
  • Next by Date: Re: Identity a hidden column in Numbers
  • Previous by thread: Sending raw Apple Events to Palm Desktop
  • Next by thread: Re: Identity a hidden column in Numbers
  • Index(es):
    • Date
    • Thread