Hello
Here is a handler designed to select a sheet in Numbers and 'open' it if it's not. Open a sheet means : reveal the names of the embedded tables.
The handler does the complete task under 10.5 and 10.6. Under 10.4.11, it selects the sheet but I can't get it opening the sheet if it isn't. The script is able to check this status. It calculates the location of the black triangle in front of the sheet's name but trying to click it changes nothing. What am'I doing wrongly ?
[applescript]
my ChangeSheetinFocus(1, "main")
--=====
on ChangeSheetinFocus(dName, sName) script myScript property lesFeuilles : {} local itIsOs4, ismySheet tell application "Numbers" activate tell document dName to set my lesFeuilles to name of sheets end tell -- Numbers
if sName is not in my lesFeuilles then set my lesFeuilles to {} if my parleAnglais() then error "The sheet “" & sName & "” is unavailable in the spreadsheet “" & d & "” !" else error "La feuille « " & sName & " » n’existe pas dans le tableur « " & d & " » ! " end if -- my parleAnglais end if -- mySheet
set itIsOs4 to 5 > (system attribute "sys2") tell application "Numbers" to activate tell application "System Events" to tell application process "Numbers" to tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window dName if itIsOs4 then set sheetSize to get size of row 1 repeat with i from 1 to (count of rows) set issName to (size of row i = sheetSize) and (get value of static text 1 of row i) is sName if issName then select row i try set nextSize to size of row (i + 1) on error set nextSize to sheetSize end try if nextSize = sheetSize then set {iX, iY} to (get position of row i) set blackTriangle to {iX + 6, iY + 11} (* position of the black triangle *) click at blackTriangle (* Alas, it doesn't open the sheet *) end if -- sh exit repeat end if end repeat else repeat with i from 1 to (count of rows) set issName to (class of UI element 1 of row i is group) and (get value of static text 1 of group 1 of row i) is sName if issName then select row i click UI element 1 of group 1 of row i exit repeat end if end repeat end if -- (system attribute… end tell -- System Events … set my lesFeuilles to {} end script run myScript end ChangeSheetinFocus
--=====
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
--===== [/applescript]
Yvan KOENIG (VALLAURIS, France) samedi 24 avril 2010 19:29:34
|