• 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: Numbers: 'make new' failing in various ways?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Numbers: 'make new' failing in various ways?


  • Subject: Re: Numbers: 'make new' failing in various ways?
  • From: KOENIG Yvan <email@hidden>
  • Date: Wed, 01 Jun 2011 10:53:48 +0200


Le 1 juin 2011 à 10:41, Axel Luttgens a écrit :


Le 1 juin 2011 à 10:03, KOENIG Yvan a écrit :

There is no bug here.
[...]

Hello Yvan,

It seems I'm in the same boat as Brennan here.
Numbers 2.0.5 (with OSX 10.6.7) insists to create the table in the document's selected sheet, not the sheet targeted in the tell statement...
There must be an explanation, but which one? ;-)

Axel

You're right, I missed this point.

Here is the complete code

my activateGUIscripting()
my selectsheet(1, "Feuille 3")
my createNewTable(1, "Feuille 3", "myNewTable", 69, 13)

on createNewTable(dName, sName, newTable, nb_rows, nb_columns)
tell application "Numbers" to tell document dName to tell sheet sName
make new table with properties {name:newTable, row count:nb_rows, column count:nb_columns}
end tell
end createNewTable

--=====

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 activateGUIscripting()
(* to be sure than GUI scripting will be active *)
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true
end tell
end activateGUIscripting
--=====
(*
==== Uses GUIscripting ====
 *)
on selectsheet(theDoc, theSheet)
script myScript
property listeObjets : {}
local maybe, targetSheetRow
--+++++
-- set log_report to "point 2 : " & (current date) & return
--+++++
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 spreadsheet “" & theDoc & "” !"
else
error "La feuille « " & theSheet & " » n’existe pas dans le tableur « " & theDoc & " » ! "
end if -- my parleAnglais
end if -- not maybe


set maybe to 5 > (system attribute "sys2")
tell application "System Events" to tell application process "Numbers"
tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc
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 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 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…
(*
Handler modified to accomodate sheets requiring a lot of time to get the focus
*)
tell targetSheetRow to set value of attribute "AXSelected" to true
set cnt to 0
repeat (*
Must way that Numbers becomes ready to receive the value *)
try
tell targetSheetRow to set value of attribute "AXDisclosing" to true
exit repeat
on error
set cnt to cnt + 1
delay 0.5 -- half a second
end try
end repeat
end tell -- outline…
end tell -- "System Events"…
--+++++
-- set log_report to log_report & "point 3, cnt = " & cnt & return & (current date) & return
--+++++
tell application "Numbers" to tell document theDoc to tell sheet theSheet to tell table 1
with timeout of 20 * 60 seconds (*
WITH this setting, the script will be able to wait 20 minutes for the asked value.
I hope that the document will not be so huge that this delay prove to be too short. *)
value of cell "A1"
end timeout
end tell -- "Numbers"…
--+++++
-- set log_report to log_report & "point 4 : " & (current date) & return
--+++++
tell application "System Events" to tell application process "Numbers" (*
Do the trick one more time to be sure that the sheet is open *)
tell targetSheetRow to set value of attribute "AXDisclosing" to true
end tell -- "System Events"…
--+++++
-- return log_report & "point 5 : " & (current date) & return
--+++++
(*
End of the modified piece of code
*)
end script
run myScript
end selectsheet

--=====


Yvan KOENIG (VALLAURIS, France) mercredi 1 juin 2011 10:53:30


 _______________________________________________
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: Numbers: 'make new' failing in various ways?
      • From: Axel Luttgens <email@hidden>
References: 
 >Re: Numbers: 'make new' failing in various ways? (From: KOENIG Yvan <email@hidden>)
 >Re: Numbers: 'make new' failing in various ways? (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Numbers: 'make new' failing in various ways?
  • Next by Date: Re: Numbers: 'make new' failing in various ways?
  • Previous by thread: Re: Numbers: 'make new' failing in various ways?
  • Next by thread: Re: Numbers: 'make new' failing in various ways?
  • Index(es):
    • Date
    • Thread