• 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
Rép: Scripting Numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: Scripting Numbers


  • Subject: Rép: Scripting Numbers
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 10 May 2010 19:53:16 +0200

Le 10 mai 2010 à 19:30, Michelle Steiner a écrit :

On May 10, 2010, at 10:23 AM, Yvan KOENIG wrote:

In other words, how do I write in the currently selected cell of the currently selected table of the currently selected sheet etc.?

Thanks
Chris

tell application "Numbers" to tell document myDoc tell sheet mySheet tell table myTable set value of cell myRow of column myColumn to myValue end tell -- table end tell -- sheet end tell -Numbers

But how does he specify which document, sheet and table based on the selection?




--=====
(*
set { dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
*)
on getSelParams()
local r_Name, t_name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_name, r_Name} to my getSelection()

if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if

set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_name)
end if
return {d_Name, s_Name, t_name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams


--=====
(*
set {rowNumber, columnNumber} to my decipher (cellRef,docName,sheetName,tableName)
apply to named row or named column !
*)
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher


--=====
(*
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
*)
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum

tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection


--=====

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

--=====

Yvan KOENIG (VALLAURIS, France) lundi 10 mai 2010 19:45:08




_______________________________________________ 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
  • Prev by Date: Re: String to real conversion question
  • Next by Date: RE: Geeting Error "Microsoft Word got an error. Connection is invalid"
  • Previous by thread: Re: Scripting Numbers
  • Next by thread: Selecting a folder from the sidebar in a save dialog
  • Index(es):
    • Date
    • Thread