• 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
Re: Reveal the tables of a sheet in Numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reveal the tables of a sheet in Numbers


  • Subject: Re: Reveal the tables of a sheet in Numbers
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 26 Apr 2010 21:21:43 +0200



Thanks to Axel Luttgens et Nigel Garvey,

problem solved.

Here are the final handlers :

--{code}
set dName to 1 (* I pass the true docName when I switch between different documents *)
set myactiveSheet to "main_1"
set myActiveTable to "Tableau 3"


my selectSheet(dName, myactiveSheet)
my selectTable(dName, myactiveSheet, myActiveTable)

--=====

on selectSheet(theDoc, theSheet)
script myScript
property listeObjets : {}
local maybe, targetSheetRow
tell application "Numbers"
activate
set theDoc to name of document theDoc (* useful if the passed value is a number *)
tell document theDoc to set my listeObjets to name of sheets
end tell -- Numbers

set maybe to theSheet is in my listeObjets
set my listeObjets to {} -- So it will not be saved in the script *)
if not maybe then
if my parleAnglais() then
error "The sheet “" & theSheet & "” is unavailable in the spreadshhet “" & d & "” !"
else
error "La feuille « " & theSheet & " » n’existe pas dans le tableur « " & d & " » ! "
end if -- my parleAnglais
end if -- not maybe

set maybe to 5 > (system attribute "sys2")
tell application "System Events" to tell application process "Numbers"
if maybe then (* macOS X 10.4.x
'(value of attributes contains 0)': '(value of attribute "AXDisclosureLevel" is 0)' sometimes works in Tiger, sometimes not.
The only possible instances of 0 amongst the attributes are the disclosure level of a sheet row and the index of the first row, which represents a sheet anyway.
Another possibility is '(value of attribute -1 is 0)', which makes me uneasy. *)
set targetSheetRow to first row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc where ((value of attributes contains 0) and (value of first static text is theSheet))
else (* macOS X 10.5.x or higher *)
set targetSheetRow to first row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc where ((value of attribute "AXDisclosureLevel" is 0) and ((groups is {}) and (value of first static text is theSheet)) or (value of first group's first static text is theSheet))
end if -- maybe…

tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}

end tell -- System Events
end script
run myScript
end selectSheet


--=====

on selectTable(theDoc, theSheet, theTable)
script myScript
property listeObjets : {}
local maybe, targetSheetRow, rowIndex, r
tell application "Numbers"
activate
set theDoc to name of document theDoc (* useful if the passed value is a number *)
tell document theDoc to set my listeObjets to name of sheets
end tell -- Numbers

set maybe to theSheet is in my listeObjets
set my listeObjets to {} -- So it will not be saved in the script *)
if not maybe then
set my listeObjets to {}
if my parleAnglais() then
error "The sheet “" & theSheet & "” is unavailable in the spreadshhet “" & d & "” !"
else
error "La feuille « " & theSheet & " » n’existe pas dans le tableur « " & d & " » ! "
end if -- my parleAnglais
end if -- not maybe

tell application "Numbers" to tell document theDoc to tell sheet theSheet to set my listeObjets to name of tables

set maybe to theTable is in my listeObjets
set my listeObjets to {} -- So it will not be saved in the script *)
if not maybe then
if my parleAnglais() then
error "The table “" & theTable & "” is unavailable in the sheet “" & theSheet & "” of the spreadshhet “" & d & "” !"
else
error "La table « " & theTable & " » n’existe pas dans la feuille « " & theSheet & " » du tableur « " & d & " » ! "
end if -- my parleAnglais
end if -- not maybe

set maybe to 5 > (system attribute "sys2")

tell application "System Events" to tell application process "Numbers"
if maybe then (* macOS X 10.4.x
'(value of attributes contains 0)': '(value of attribute "AXDisclosureLevel" is 0)' sometimes works in Tiger, sometimes not.
The only possible instances of 0 amongst the attributes are the disclosure level of a sheet row and the index of the first row, which represents a sheet anyway.
Another possibility is '(value of attribute -1 is 0)', which makes me uneasy. *)
set targetSheetRow to first row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc where ((value of attributes contains 0) and (value of first static text is theSheet))
else (* macOS X 10.5.x or higher *)
set targetSheetRow to first row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc where ((value of attribute "AXDisclosureLevel" is 0) and ((groups is {}) and (value of first static text is theSheet)) or (value of first group's first static text is theSheet))
end if -- maybe
tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}
(*
Awful trick to get the row index *)
try
targetSheetRow as text (* to issue an error *)
on error errMsg (*
(errMsg as text) is :
*Impossible de transformer «class crow» 4 of «class outl» 1 of «class scra» 1 of «class splg» 1 of «class splg» 1 of window "attributs.numbers" of «class pcap» "Numbers" of application "System Events" en type string.*)
set rowIndex to item 1 of my decoupe(item 2 of my decoupe(errMsg as text, "» "), space)
end try
tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc
repeat with r from rowIndex to count of rows
if value of first static text of row r is theTable then
select row r
exit repeat
end if -- value…
end repeat
end tell -- outline 1 …
end tell -- System Events
end script
run myScript
end selectTable


--=====

on parleAnglais()
	local z
	try
		tell application "Numbers" to set z to localized string "Cancel"
	on error
		set z to "Cancel"
	end try
	return (z is not "Annuler")
end parleAnglais

--=====

on decoupe(t, d)
	local l
	set AppleScript's text item delimiters to d
	set l to text items of t
	set AppleScript's text item delimiters to ""
	return l
end decoupe

--=====
--{code}

Yvan KOENIG (VALLAURIS, France) lundi 26 avril 2010 21:21:15



_______________________________________________
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
References: 
 >Reveal the tables of a sheet in Numbers (From: Yvan KOENIG <email@hidden>)
 >Re: Reveal the tables of a sheet in Numbers (From: Axel Luttgens <email@hidden>)
 >Re: Reveal the tables of a sheet in Numbers (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: SMS Via iChat
  • Next by Date: Synchronize 2 folders over the Internet
  • Previous by thread: Re: Reveal the tables of a sheet in Numbers
  • Next by thread: test
  • Index(es):
    • Date
    • Thread