Here is an enhanced version which no longer use a loop to extract the selected values.
--{code}
set destinationFolder to "MacHD:/Users//Documents/Work/Customers/:to:folder:"
(*
tell application "Numbers.app"
set theCells to value of range "A1:A211" of active sheet
end tell
repeat with oneCell in theCells
tell application "Finder" to make new folder at folder destinationFolder with properties {name:item 1 of oneCell}
end repeat
*)
set destinationFolder to "" & (path to desktop) & " dossier"
(*
Select the range of source cells then run the script *)
(*
Grab parameters describing the selected cells *)
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
(*
Extract the names from the selected cells *)
tell column colNum1
set theNames to value of cellsrowNum1 thru rowNum2
end tell -- column
end tell -- Numbers
(*
I always do my best to use System Events which is faster than the Finder *)
tell application "System Events"
repeat with aName in theNames
try
makenewfolderat end of folderdestinationFolderwith properties {name:aName as text}
end try
end repeat
end tell
--=====
(*
set { dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
*)
on get_SelParams()
local d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2
tell application "Numbers" to tell document 1
set d_Name to its name
set s_Name to ""
repeat with i from 1 to the count of sheets
tell sheet i to set maybe to the count of (tables whose selection range is not missing value)
if maybe is not 0 then
set s_Name to name of sheet i
exit repeat
end if -- maybe is not 0
end repeat
if s_Name is "" then
if my parleAnglais() then
error "No sheet has a selected table embedding at least one selected cell !"
else
error "Aucune feuille ne contient une table ayant au moins une cellule sélectionnée !"
end if
end if
tell sheet s_Name to tell (first table where selection range is not missing value)
tell selection range
set {top_left, bottom_right} to {name of first cell, name of last cell}
end tell
set t_Name to its name
tell cell top_left to set {row_Num1, col_Num1} to {address of its row, address of its column}
if top_left is bottom_right then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
tell cell bottom_right to set {row_Num2, col_Num2} to {address of its row, address of its column}
end if
end tell -- sheet…
return {d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end tell -- Numbers
end get_SelParams
--=====
on parle_anglais()
return (do shell script "defaults read 'Apple Global Domain' AppleLocale") does not start with "fr_"
end parle_anglais
--=====
--{code}
Here is an alternate version of the piece of code extracting the values :
--{code}
(*
Grab parameters describing the selected cells *)
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
(*
Extract the names from the selected cells *)
set cell1 to name of cell rowNum1 of column colNum1
set cell2 to name of cell rowNum2 of column colNum1
set theNames to value of cells of range (cell1 & ":" & cell2)
end tell -- Numbers
--{code}
Yvan KOENIG (VALLAURIS, France) mercredi 25 janvier 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k