Script + VoiceOver in Numbers
I'm trying to create a dictionary for learning new English words. f.e. I have already some list of words in my Numbers document and I want "learn" pronounce of this words with VoiceOver or embed utility in Numbers. I know, that iWork doesn't have something like MS Office macro. How I can play pronounce of my words automatically? AppleScript?
Thanks!
danilabagroff,
This works for me, but I can't recall if the speech capability was a standard feature or if it came with a download such as WordService. It's worth a try - not difficult.
Triple-Click the cell that has the content that you want the computer to speak. Then go to:
Numbers > Services > Speech > Start Speaking Text.
If that works for you, then you can make a keyboard shortcut to eliminate having to traverse the menu structure.
I'll give you the keyboard combination that I used to test this before posting, you could choose a different key combination.
1. Open System Preferences and select Hardware > Keyboard and Mouse.
2. Scroll to the bottom of the list in the shortcut pane and click the triangle next to Application Keyboard Shortcuts to expand the list.
3. Scroll to the bottom and click the triangle next to All Applications
4. Click on All Applications to select it and then click the + button just below the left edge of the list.
5. In the Menu Title input field, type Start Speaking Text.
6. In the Keyboard Shortcut input field, type Control-Option-S.
7. Click the Add button.
Now anytime that you have a block of Selected Text, as happens when you triple-click a cell, you can press Control-Option-S and the speaking should begin.
Regards,
Jerry
Similar Messages
-
Script for converting numbers?
Hi guys,
Do you know how to make a script to change numbers between parenthesis in superscript without the parenthesis? The author send me the texts this way I have made a Character style of the Superscript but still and it a bit time consumming changing them one by one all the time.
I have an image which explain it better.
http://www.pixentral.com/show.php?picture=1vNdYe7ciMEbwqbUWAIrmPY0Gh4a8
Thanks for any help or info. I would really appreciate it
Cheers,
SUse GREP Search and replace (Find/Change dialog):
Have fun -
There us to be a "script" for ticket numbering. What happened to it?
In InDesign, there use to be an available "script" for ticket numbering. (Multi tickets on a page and several pages, that I could arrange to be cut in stacks and retain their order.) I use to use it in CS5 and CS6... but when I went to CC the script is gone. I think it was a third party "script". Please help. I need it soooooooo badly.
Hi Peter,
What you say is what you want !
So, make a master page as :
And launch this clever [JS] written by Jared Katz. Define your settings and "OK".
Done!
page 1…
… to last page! -
How to show script menu in numbers.
I just bought from AppleStore the Numbers aplication and I am not able to get the script menu to show up in numbers.
Script menu is already selected in Editor Applescript and in fact the menu shows up in ALL other applications like iCalc, Safari, Finder, etc..
I have a MacBook Pro with Lion 10.7.3
Any help will be gratly appreciate.In the English version, the Number menu bar requires about 700 pixels.
The French one requires 850 pixels.
It's the user's duty to define the list of actions reachable from the right area of the menu bar to fit in the available area.
Here you may see a heavily loaded menu bar.
Yvan KOENIG (VALLAURIS, France) mardi 14 février 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k -
Using Voiceover in Numbers for iPad
I am a blind iPad Mini user looking for the correct gestures for using the Numbers App with VoiceOver. I am not understanding how to navigate the spreadsheets or make changes in them. Does anyone know of a good resource for this? All the ones I have found online are not specific to the Numbers App.
I have submitted an enhancement request via Apple's iPad feedback and hoping that future versions of Numbers for iPad would have the ability to password protect table cells, and also have the abilty to disable the delete function within Forms.
Would appreciate any further halp on a possble workaround in the mean time.
Thanks -
Scripting for different numbers of table rows in cs3
As always thank you for the help.
My question: is there a simple newbie way to script for stroke placements when the numbers of rows in the category between the stroke will vary. I have not even attempted to script this style, as frankly I don't know where to start, but here is an explanation of what I need:
The table foodstuff contains:
animal, vegetable, fruit
Under animal there is:
beef, lamb, pork, poultry
Under vegetable there is:
potato, pepper, onion
Under fruit there is:
orange
If wanted a line under each category, ie after poultry, after onion, and after orange how would I go about it.
Thank you to all who have helped me so far, either by reading answers to other people's queries, or by responding directly to my ownInteresting ... I don't think there is a newbie-level answer to this challenge. It comes down to finding the first (left-to-right) cell that contains text, and adding a line on top of it all the way to the last cell in that row.
Here's a first attempt:
table = app.selection[0];
if (table.hasOwnProperty("baseline"))
table = table.parent;
if (table instanceof Cell)
table = table.parent;
if (table instanceof Column)
table = table.parent;
if (table instanceof Row)
table = table.parent;
if (table instanceof Table)
table.cells.everyItem().properties = {topEdgeStrokeWeight:0, bottomEdgeStrokeWeight:0, leftEdgeStrokeWeight:0, rightEdgeStrokeWeight:0};
table.rows.lastItem().bottomEdgeStrokeWeight = 1;
for (r=0; r<table.rows.length; r++)
for (c=0; c<table.rows[r].cells.length; c++)
if (table.rows[r].cells[c].contents)
for (; c<table.rows[r].cells.length; c++)
table.rows[r].cells[c].topEdgeStrokeWeight = 1;
break;
} else
alert ("You were supposed to be somewhere inside a Table"); -
Listing Bookmark Script Align Page Numbers to Right
Hello,
I have a script which will list Bookmark Names and then the Page Number after the bookmark as follows:
Bill Smith Page#1
Jeffrey Jones Page#5
Christopher James Page#8
What I would like the script to achieve is to list the bookmarks and then align the Page numbers to the right side of the pdf instead of jumbled together.
Can anyone please advise if it is possible to do this in javascript?
The existing code is as follows:
/* List all Bookmarks */
/* Recursively work through bookmark tree */
function PrintBookmarks(bm, nLevel)
if (nLevel != 0) { // don't print the root
bmReport.absIndent=bmTab*(nLevel-1);
bm.execute();
bmReport.writeText(" "+bm.name +" Page "+(bm.doc.pageNum +1));
if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)
PrintBookmarks(bm.children[i], nLevel + 1);
bmTab = 20;
bmReport = new Report();
bmReport.size = 2;
bmReport.writeText(this.title);
bmReport.writeText(" ");
bmReport.size = 1.5;
bmReport.writeText("Listing of Bookmarks");
bmReport.writeText(" ");
bmReport.size = 1;
PrintBookmarks(this.bookmarkRoot, 0);
global.bmRep = bmReport; // make global
global.wrtDoc = app.setInterval(
'try {'
+' reportDoc = global.bmRep.open("Listing of Bookmarks");'
+' console.println("Executed Report.open");'
+' app.clearInterval(global.wrtDoc);'
+' delete global.wrtDoc;'
+' console.println("Executed App.clearInterval");'
+' reportDoc.info.title = "Bookmark Listings";'
+' reportDoc.info.Author = "List Bookmark Sequence";'
+'} catch (e) {console.println("Waiting...: " + e);}'
, 100);
Any help will be much appreciatedThank you very much for your help.
I have modified the script to have the bookmarks and page numbers on separate lines, however the indent does not go further than the middle of the page on the seconde line for the page numbers, no matter how much the indent is modifed (I am also using version 8 of Adobe).
Can you please advise how to get the indent to increment past the middle of the page to the right side of the page?
The script which has been modified is as follows:
/* List all Bookmarks first then Page Numbers */
/* Recursively work through bookmark tree */
function PrintBookmarks(bm, nLevel)
if (nLevel != 0) { // don't print the root
bmReport.absIndent=bmTab*(nLevel-1);
bm.execute();
bmReport.writeText(" "+bm.name);
bmReport.absIndent=(580);
bmReport.writeText(" Page "+(bm.doc.pageNum +1));
if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)
PrintBookmarks(bm.children[i], nLevel + 1);
bmTab = 20;
bmReport = new Report();
bmReport.size = 2;
bmReport.writeText(this.title);
bmReport.writeText(" ");
bmReport.size = 1.5;
bmReport.writeText("Listing of Bookmarks");
bmReport.writeText(" ");
bmReport.size = 1;
PrintBookmarks(this.bookmarkRoot, 0);
global.bmRep = bmReport; // make global
global.wrtDoc = app.setInterval(
'try {'
+' reportDoc = global.bmRep.open("Listing of Bookmarks");'
+' console.println("Executed Report.open");'
+' app.clearInterval(global.wrtDoc);'
+' delete global.wrtDoc;'
+' console.println("Executed App.clearInterval");'
+' reportDoc.info.title = "Bookmark Listings";'
+' reportDoc.info.Author = "List Bookmark Sequence";'
+'} catch (e) {console.println("Waiting...: " + e);}'
, 100); -
Script to change numbers all at once...
Hi,
I work with technical drawings...90% of my time is changing the numbers on the drawing. I take the PDF that was created in UG/NX and then open that in Illustrator to make formatting changes, and number changes.
What I would love, is to have a script that will let me take an excel file, text file (something) the file would list the current numbers and list the new numbers, and have the illustrator script switch all the numbers at once.
I know there is the find and replace but that takes too long, and I have to worry about if I'm changing 2 to 5, that it's not going to change 20 to 50. Even with the script that would be a concern.
Is what I want even doable with a script, and do you have any suggestions on how to get started? I have someone who can help me with the code, just want to see if it's even possible.
Sample list would look something like,
Old number, New Number
1, 5
2, 6
3, 7
4, 8
5, 9
6, 10
7, 11
8, 12
9, 13
10,
11, 14
12, 15
13, 16
15,
16, 17
Numbers can go into the 400's
TIA
Karleenthanks for answering me.
One number is never replaced by two different numbers.
How would I get started working on the code? VB, Java? Any tips or suggestions would be great.
Thanks! -
How to run scripts in Numbers?
In Yvan Koenig's script, the instructions say
"Save the script as a Script: numberInLetters.scpt
Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Put the cursor in the cell which contains the number to translate.
menu Scripts > Numbers > numberInLetters"
What I have done so far:
placed a script in that location
checked option in AppleScript Editor "Show Script menu in menu bar"
closed and opened Numbers since doing all that
Still no Script menu.
What else do I need to do to get the Script menu to display in Numbers?Hi kharisma,
This is what did with the script:
Selected everything from (* to --[/SCRIPT] (omitting {code} )
Pressed command-C to Copy.
Opened AppleScript Editor.
Went AppleScript Editor > Preferences.
Checked "show Script menu in Menu bar"
Closed preferences.
Clicked in the script area and Pasted.
Went File > Save to open the Save Dialogue.
Chose Script from the File Format: popup menu.
Navigated to the Desktop and clicked Save.
Switched to Finder and opened a Finder window.
Pointed the window to the Desktop. Sorted by Date to bring the newly saved file to the top.
(Later repeated the steps above, saving the same script as an Application with the name Num2wdsResults. Moved both to the folder noted below.)
Clicked otside the window to deslelect it.
Pressed and held the option key.
Went Go > Library to open my user Library.
Released option key.
Navigated/constructed path to Library > Scripts > Applications > Numbers.
Dragged newly saved file to the newly made Numbers folder.
Launched Numbers (which opened a new blank document)
Entered numbers in A2 through A11.
Selected each in turn and went Script menu > Numbers2words
(or on alternate rows, Script menu > num2wds)
Resuts as shown. Note the limitations demonstrated in the yellow rows.
The script may be saved as either a Script or an Application. Both produce the same results.
To run either from within Numbers, select a cell containing a number, then select the script from the Script menu in Numbers.
Regards,
Barry -
In Numbers 08 is it possible to add a link to a file on the local disc within a cell?
In Numbers 08 is it possible to add a link to a file on the local disc within a cell?
As it's a feature asked several times, maybe it will be available in the next version.
I don't know features available in Excel.
Sometimes ago I posted an AppleScript which may perhaps fit your needs.
If you insert in a table pathnames of files stored in your HD, select the cell, trigger the script, open the file.
Here is an updated version :
--[SCRIPT open_a_file]
Enregistrer le script en tant que Script : open_a_file.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Library:Scripts:Applications:Numb ers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner la cellule contenant le chemin d'accès
Aller au menu Scripts , choisir Numbers puis choisir “open_a_file”
ouvre le fichier.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: open_a_file.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select the cell containing the pathname
Go to the Scripts Menu, choose Numbers, then choose “open_a_file”
open the file
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Save this script as a … Script in the "Folder Actions Scripts" folder
<startupVolume>:Library:Scripts:Folder Action Scripts:
--=====
Yvan KOENIG (VALLAURIS, France)
2010/02/02
2011/04/28 - replaced the getSelParams handler by the get_SelParams one
--=====
on run
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
set maybe to value of cell rowNum1 of column colNum1
end tell -- Numbers
tell application "Finder" to open maybe
end run
--=====
set { dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
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 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
--=====
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
--=====
--[/SCRIPT]
Oops, I forgot that you are asking about Numbers '08 which hasn't AppleScript support.
Yvan KOENIG (VALLAURIS, France) jeudi 28 avril 2011 16:26:39
Please :
Search for questions similar to your own before submitting them to the community -
Use of applescript in numbers to automatically analyze data?
Hi all,
I am trying to figure out if it is possible to use applescript and numbers to achieve the following:
(1) Import a CSV file
(2) Work out an average and standard deviation for particular columns of data in that CSV file
(3) Copy and paste out those averages and standard deviations to a separate numbers file, along with the name of the original data file, so in the end I have a file that contains a number of rows, each one containing the results for each data file and the file name.
The files (from an analytical instrument) are all the same, so ideally I could use automator and/or applescript to automatically run through a directory of csv files to achieve this.
I know only a small amount of very basic programming. I don't want someone to write this for me, but if someone could offer some pointers or examples that would be very helpful. Or tell me that what I am trying to do is foolish, and use something else instead.
ThanksAs I got a sample file, I was able to build a script matching the full requirements.
Here is a revised version which may be useful for other users.
--[SCRIPT average&stdev_CSV]
Enregistrer le script en tant que Script : average&stdev_CSV.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
aller au menu Scripts , choisir Numbers puis choisir average&stdev_CSV
Sélectionner un dossier contenant des fichiers CSV.
Le script ouvre ces fichiers dans Numbers,
calcule les valeurs MOYENNE() et ECARTYPE()
écrit celles-ci avec le nom du document dans un fichier texte.
Après traitement de tous les fichiers le fichier texte et ouvert dans Numbers.
On peut également enregistrer le script en tant que progicile (application sou 10.6.x).
Il suffira alors de glisser/déposer l'icone du dossier à traiter sur celle du script_application.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: average&stdev_CSV.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
go to the Scripts Menu, choose Numbers, then choose "average&stdev_CSV"
Select a folder containing CSV files.
The script open them in Numbers,
calculate the AVERAGE() and STDEV() values
write them with the file name in a text file.
When all files are treated, the text file is opened in Numbers.
You may also save the script as an application package (application under 10.6.x).
Then drag & drop the icon of the folder to treat on the scipt_application icon.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (VALLAURIS, France)
2010/06/10
2010/06/11 -- now read the csv file only once
--=====
property permis : {"public.comma-separated-values-text", "public.csv"}
property AVERAGE_loc : missing value
property STDEV_loc : missing value
property delim : missing value
property deci : missing value
property altDelim : missing value
property altDeci : missing value
property dossier_temporaire : missing value
property mon_Rapport : missing value
--=====
Entry point used when we double click the script's icon
or when we call it from the Scripts menu .
on run
if my parleAnglais() then
set le_prompt to "Choose a folder containing CSV file …"
else
set le_prompt to "Choisir un dossier contenant des fichiers CSV …"
end if -- parleAnglais
my main(choose folder with prompt le_prompt without invisibles)
end run
--=====
Entry point used when we drag & drop a folder icon on the application_script's icon
on open sel
my main(sel)
end open
--=====
on main(selected_item) -- it's an alias
local isFolder, nomdurapport, les_fichiers, type_ID, un_fichier, nombrededocuments, nomdutableur
the selected folder's pathname
set selected_item to selected_item as text
tell application "System Events"
set isFolder to class of disk item selected_item is folder
end tell -- System Events
if not isFolder then
if my parleAnglais() then
error "You must select a folder containing CSV file …"
else
error "Vous devez choisir un dossier contenant des fichiers CSV …"
end if -- parleAnglais
end if -- not isFolder
Init once variables which will be used later.
set dossier_temporaire to (path to temporary items) as text (* property *)
set AVERAGE_loc to my getLocalizedFunctionName("Numbers", "AVERAGE") & "(" (* property *)
set STDEV_loc to my getLocalizedFunctionName("Numbers", "STDEV") & "(" (* property *)
set {delim, deci, altDelim, altDeci} to my getLocalized_Delimiters() (* properties *)
set nomdurapport to "resume" & my dateTimeStamp() & ".txt" (* locale *)
set mon_Rapport to dossier_temporaire & nomdurapport (* property *)
Extract the list of items stored in the selected folder.
Create the resumeyyyymmddhhmmss.txt temporary file.
tell application "System Events"
set les_fichiers to every disk item of folder selected_item
make new file at end of folder dossier_temporaire with properties {name:nomdurapport}
end tell
Scan the items stored in the folder.
Skip the folders and documents which aren't csv ones.
repeat with un_fichier in les_fichiers
tell application "System Events"
if class of un_fichier is folder then
set type_ID to "Oops, I‘m a folder" (* so it will not be deciphered *)
else
set type_ID to type identifier of un_fichier
set un_fichier to path of un_fichier
end if
end tell -- System Events
if type_ID is in my permis then my traiteun_fichier(unfichier)
end repeat -- with un_fichier
The scan is done, open the resumeyyyymmddhhmmss.txt temporary file in Numbers.
tell application "Numbers"
set nombrededocuments to count of documents
open mon_Rapport
repeat while (count of documents) = nombrededocuments
delay 0.2
end repeat
set nomdutableur to name of document 1
Set cells format to the Scientific one but I can't define the number of decimals !
tell document 1 to tell sheet 1 to tell table 1
set format of range ("B1 : " & name of last cell) to scientific
end tell
save document 1 in (selected_item & nomdutableur)
end tell -- Numbers
Delete the temporary text file
tell application "System Events" to delete disk item mon_Rapport
Reset properties so there content will not be stored in the script
set AVERAGE_loc to missing value
set STDEV_loc to missing value
set delim to missing value
set altDelim to missing value
set deci to missing value
set altDeci to missing value
set dossier_temporaire to missing value
set mon_Rapport to missing value
end main
--=====
on traiteunfichier(unFichier) (* text item *)
local dossierdetravail, nomdu_csvtemporaire, csv_temporaire, utile, cnt, part2
local |dernière|, nombreDeDocuments, nomdutableur, laPlage
tell application "System Events"
tell disk item unFichier
set dossierdetravail to path of container -- of disk item unFichier
set nomdu_csvtemporaire to name -- of disk item unFichier
end tell -- unFichier
if nomdu_csvtemporaire does not end with ".csv" then set nomdu_csvtemporaire to nomdu_csvtemporaire & ".csv"
set csv_temporaire to (dossier_temporaire & nomdu_csvtemporaire)
if exists disk item csv_temporaire then delete disk item csv_temporaire
make new file at end of folder dossier_temporaire with properties {name:nomdu_csvtemporaire}
end tell -- System Events
Read the entire file
set utile to (read file unFichier)
Check that it's matching our requirements. I'm not sure that the second test is always valid.
if (utile contains "#=-=-=-=-=-=-=-=-=") and utile contains "#=-=-=-=-=-=-=-=-=End ./conf/ccia" then
set cnt to offset of "#=-=-=-=-=-=-=-=-=" in utile
Extract the second part which isn't formatted as the first one.
set part2 to text cnt thru -1 of utile
Extract the first part to decipher it.
set utile to (text 1 thru (cnt - 1) of utile) as text
Grabs the index of lower row
set |dernière| to count of (paragraphs of utile)
An ultimate test to be sure that the file is for us.
if (|dernière| > 0) and text -13 thru -2 of (paragraph 6 of utile) is "NFitsAvg'd" then
Normalize the datas according to the local settings
if not ((utile contains delim) and utile contains deci) then
if utile contains altDelim then set utile to my remplace(utile, altDelim, delim)
if utile contains altDeci then set utile to my remplace(utile, altDeci, deci)
end if
Write the normalized beginning and the untouched part2 in a temporary csv file.
write utile to file csv_temporaire
write part2 to file csv_temporaire starting at eof
Open the temporary csv in Numbers
tell application "Numbers"
set nombreDeDocuments to count of documents
open csv_temporaire
repeat while (count of documents) = nombreDeDocuments
delay 0.2
end repeat
set nomdutableur to name of document 1
tell document 1 to tell sheet 1 to tell table 1
Insert a row at top to insert the required formulas.
add row above first row
Insert the formulas calculating the AVERAGEs and the STDEVs .
repeat with c from 2 to 16 by 2
set laPlage to (name of cell 8 of column c) & " : " & name of cell |dernière| of column c
set value of cell 1 of column c to "=" & AVERAGE_loc & laPlage & ")"
set value of cell 1 of column (c + 1) to "=" & STDEV_loc & laPlage & ")"
end repeat -- with c
Extract the calculated values to build a new row in the resume.
set une_ligne to {nomdu_csvtemporaire}
tell row 1
repeat with c from 2 to 17
copy (value of cell c) as text to end of une_ligne
--copy (value of cell c) to end of une_ligne
end repeat
end tell -- row 1
end tell -- document
Save the new Numbers document.
I don't know if it is useful but it's easy to remove or disable the instruction.
save document 1 in (dossierdetravail & nomdutableur)
close document 1 saving no (* So, if you disable the Save instruction, it will close quietly *)
end tell -- Numbers
Write the new row in the resume text file.
write (my recolle(une_ligne, tab) & return) to file mon_Rapport starting at eof
end if -- (|dernière| > 0) or
end if -- read file unFichier…
Delete the temporary csv file
tell application "System Events" to delete file csv_temporaire
end traiteunfichier
--=====
Creates a new iWork document from the Blank template and returns its name.
example:
set myNewDoc to my makeAnIworkDoc(theApp)
on makeAnIworkDoc(theApp)
local t, n
if theApp is "Pages" then
set commun to "iWork '" & my get_iWorkNum("Pages") & ":Pages.app:Contents:Resources:Templates:Blank.template:"
try
set t to ((path to applications folder as text) & commun) as alias
on error
set t to ("Western 2:Applications communes:iWork '" & commun) as alias
end try
else if theApp is "Numbers" then
set commun to "iWork '" & my get_iWorkNum("Numbers") & ":Numbers.app:Contents:Resources:Templates:Blank.nmbtemplate:"
try
set t to ((path to applications folder as text) & commun) as alias
on error
set t to ("Western 2:Applications communes:" & commun) as alias
end try
else
if my parleAnglais(theApp) then
error "The application “" & a & "“ is not accepted !"
else
error "l’application « " & a & " » n’est pas gérée !"
end if
end if
tell application theApp
set n to count of documents
open t
repeat until (count of documents) > n
delay 0.1
end repeat
set n to name of document 1
end tell -- theApp
return n
end makeAnIworkDoc
--=====
on dateTimeStamp()
return (do shell script "date +_%Y%m%d-%H%M%S")
end dateTimeStamp
--=====
Set the parameter delimiters which must be used in Numbers formulas
on getLocalized_Delimiters()
if character 2 of (0.5 as text) is "." then
return {",", ".", ";", ","}
else
return {";", ",", ",", "."}
end if
end getLocalized_Delimiters
--=====
on get_iWorkNum(a)
local verNum
tell application a to set verNum to item 1 of my decoupe(get version, ".")
if (a is "Numbers" and verNum is "2") or (a is "Pages" and verNum is "4") then
return "09"
else
return "11"
end if
end get_iWorkNum
--=====
Useful to get function's localized name if we need to build formulas
examples:
set OFFSET_loc to my getLocalizedFunctionName("Numbers", "OFFSET")
set ADDRESS_loc to my getLocalizedFunctionName(theApp, "ADDRESS")
set INDIRECT_loc to my getLocalizedFunctionName(theApp, "INDIRECT")
on getLocalizedFunctionName(theApp, x)
return my getLocalizedName(theApp, x, (path to application support as text) & "iWork '" & ¬
my get_iWorkNum(theApp) & ":Frameworks:SFTabular.framework:Versions:A:Resources:")
end getLocalizedFunctionName
--=====
on getLocalizedName(a, x, f)
tell application a to return localized string x from table "Localizable" in bundle file f
end getLocalizedName
--=====
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 TIDs, l
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to TIDs
return l
end decoupe
--=====
on recolle(l, d)
local TIDs, t
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to TIDs
return t
end recolle
--=====
replaces every occurences of d1 by d2 in the text t
on remplace(t, d1, d2)
local TIDs, l
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to TIDs
return t
end remplace
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) vendredi 11 juin 2010 19:01:46 -
Save as- for Dummies (Numbers version)
Here is a clean way to retrieve Save As… in Numbers.
--(SCRIPT Numbers_save_a_copy]
Enregistrer le script en tant que Script : Numbers_save_a_copy.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications :Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Aller au menu Scripts , choisir Numbers puis choisir “Numbers_save_a_copy”
Le script enregistre une copie du document au premier plan
au format natif de Numbers en ajoutant la date et l'heure au nom du fichier.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++++
Save the script as a Script: Numbers_save_a_copy.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Go to the Scripts Menu, choose Numbers, then choose “Numbers_save_a_copy”
The script saves the frontmost document
in the native Numbers format in a date_time stamped file.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox
--=====
Yvan KOENIG (VALLAURIS, France)
2011/08/12
on run
local docPath, docName, docFolder, fileName, theExt, newName, newPath
set major_OS to get system attribute "sysv"
Grab infos about the open doc at front *)
tell application "Numbers"
tell document 1
set docPath to its path
set docName to its name
end tell
if major_OS ≥ 4208 then save docName (* Required for Lion *)
end tell
Grab infos about the file from which the doc was open *)
tell application "System Events" to tell disk item docPath
set docFolder to path of container
set fileName to name
set theExt to name extension
end tell
Build an unique name for the new document *)
if theExt is not "" then
set newName to (text 1 thru -(2 + (length of theExt)) of fileName) & (do shell script "date +_%Y%m%d_%H%M%S.") & theExt
else
set newName to fileName & (do shell script "date +_%Y%m%d_%H%M%S")
end if
Create the new file *)
tell application "System Events"
make new file at end of folder docFolder with properties {name:newName}
end tell
set newPath to (docFolder & newName) as alias
Save a copy in the newly created file *)
tell application "Numbers"
save document docName in newPath
end tell
end run
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) vendredi 19 août 2011 22:18:22
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
My iDisk is : <http://public.me.com/koenigyvan>Here is an other one.
Read carefully the explanations given at the very beginning, in French then in English.
With this one you master the time when you save. CAUTION, Autosave is unable to do it's duty when you work on a document open with the script so don't forget to ask the script to save from time to time.
With this dedicated to Numbers script, the most interesting piece of code is the one used to grab the status of the document when we open it to be able to reset it after inserting the items storing the path to folder to save in and the doc shortname.
--(SCRIPT Numbers_without_autosave]
Enregistrer le script en tant qu'application sur le Bureau.
Glisser une icône de document Numbers sur l'icône de l’application
ouvre le document, le duplique, ferme l'original renomme la copie en ajoutant l'information date_heure
crée une table dans une feuille afin d'y stocker le chemin d'accès au dossier source et le nom court du document original.
Travailler sur le document et de temps à autres, cliquer sur l'cône du script application afin d'enregistrer
le document et repartir avec une copie qui n'ayant jamais été enregistré ne sera pas autoenregistré.
Bien entendu, quand vous aurez fini de travailler sur le document il vous faudra l'enregistrer comme autrefois.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++++
Save the script as an application on the Desktop.
Drop a Numbers doc icon on the application's one, open the document, duplicate it, save the original if it was created from a template,
rename the duplicate inserting a date_time stamp, create a table in a sheet to store the pathname to the source folder and the short name of the original.
After that you may work upon the document. From time to time, click the script's icon to save the document and replace it by a fresh replicate. So this one which was never saved will not be autosaved.
When you have finished to work upon the doc, save it as you did in the past.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox
--=====
Yvan KOENIG (VALLAURIS, France)
2011/08/22
property permitted : {"com.apple.iWork.Numbers.numbers", "com.apple.iWork.Numbers.sffnumbers"}
property modeles : {"com.apple.iWork.Numbers.template", "com.apple.iWork.Numbers.sfftemplate"}
property boxName : "pathname_shortname_emantrohs_emanhtap"
--=====
on run
local docName, path_infos, docFolder, nomCourt, docPath, nbd
my controle_versions()
Grab infos about the frontmost Numbers document *)
tell application "Numbers"
set docName to name of document 1
tell document docName
Try to extract the infos stored by the open handler *)
try
tell sheet boxName to tell table boxName
set docFolder to value of cell "A1"
set nomCourt to value of cell "B1"
end tell
on error
if my parleAnglais() then
error "The document “" & docName & "”" & return & "wasn’t open with this script !"
else
error "Le document « " & docName & " »" & return & "n’a pas été ouvert avec ce script !"
end if
end try
end tell -- document
end tell -- Numbers
set docPath to docFolder & docName
tell application "System Events"
This test was useful during my tests, now it's useless *)
if not (exists disk item docPath) then
make new file at end of folder docFolder with properties {name:docName}
end if
end tell -- System Events
set docPath to docPath as alias
I don't understand why I must apply save - close - open but without that it fails *)
tell application "Numbers"
save document docName in docPath
close document docName
open docPath
set nbd to count of documents
end tell
my selectMenu("Numbers", 3, 9) (* Duplicate ( 9 in Numbers, 10 in Pages )*)
Wait the availability of the duplicate *)
tell application "Numbers"
repeat 100 times
if (get count of documents) > nbd then exit repeat
delay 0.2
end repeat
Now we may close the 'old' document *)
close document docName without saving
end tell -- Numbers
Build a date_time stamped name for next version *)
set docName to nomCourt & my build_a_stamp() & ".numbers"
tell application "Numbers"
set name of document 1 to docName
end tell
end run
--=====
on open (sel)
local docPath, docFolder, fileName, theExt, typeID, nomCourt, nouveauNomCourt, newPath, oldUnits, docName, nbd
Apply consistency checks *)
my controle_versions()
set docPath to sel's item 1 (* Here, docPath is an alias *)
Extract some infos about the original document *)
tell application "System Events" to tell disk item (docPath as text)
set docFolder to path of container
set fileName to name
The try block may be useful if an user is fool enough to drag & drop a folder on the scrip’s icon *)
try
set theExt to name extension
on error
set theExt to ""
end try
try
set typeID to type identifier
on error
set typeID to ""
end try
end tell
Check that the dragged item is a Numbers document *)
if (typeID is not in permitted) and (typeID is not in modeles) then error number -128
Strip the name extension if there is one *)
if theExt is not "" then
set nomCourt to (text 1 thru -(2 + (length of theExt)) of fileName)
else
set nomCourt to fileName
end if
If the original is a template, we will save the newly created file *)
if typeID is in modeles then
set nouveauNomCourt to nomCourt & my build_a_stamp()
set fileName to nouveauNomCourt & ".numbers"
Create a new file *)
tell application "System Events"
make new file at end of folder docFolder with properties {name:fileName}
end tell
set newPath to (docFolder & fileName) as alias
end if
tell application "Numbers"
open docPath
if typeID is in modeles then
Original is a template so save the new doc once *)
save document 1 in newPath
set name of document 1 to fileName
end if
set docName to name of document 1
set nbd to count of documents
end tell
my selectMenu("Numbers", 3, 9) (* Duplicate ( 9 in Numbers, 10 in Pages )*)
Wait the availability of the duplicate *)
tell application "Numbers"
repeat 100 times
if (get count of documents) > nbd then exit repeat
delay 0.2
end repeat
Now may close the 'original' document *)
close document docName without saving
end tell
set docName to nomCourt & my build_a_stamp() & ".numbers"
tell application "Numbers"
set name of document 1 to docName
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell document docName
make new sheet with properties {name:boxName}
tell sheet boxName
delete table 1
make new table with properties {name:boxName, row count:2, column count:3}
tell table boxName
remove column 1
remove row 1
set value of cell "A1" to docFolder
set value of cell "B1" to nomCourt
end tell -- table
end tell -- sheet
Reset the entry settings *)
if tName is "" then
my selectSheet(dName, sName)
else
my selectTable(dName, sName, tName)
if rowNum1 > 0 then
tell sheet sName to tell table tName
set selection range to range (name of cell rowNum1 of column colNum1 & ":" & name of cell rowNum2 of column colNum2)
end tell
end if
end if
end tell -- document
end tell -- Numbers
end open
--=====
on build_a_stamp()
return do shell script "date +_%Y%m%d_%H%M%S"
end build_a_stamp
--=====
on controle_versions()
local app_Version, sysv
tell application "Numbers" to set app_Version to version
set sysv to system attribute "sysv"
if (app_Version < "2.1") or (sysv < 4208) then error number -128
end controle_versions
--=====
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
Enhanced version returning the name of the selected sheet or the name of the selected table if no cell is selected *)
on get_SelParams()
script myScript
property liste_feuilles : {}
local d_name, s_name, t_name, row_num1, col_num1, row_num2, col_num2
local sheet_size, i, r, s, t_index, sheet_row
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
end tell -- Numbers…
if s_name > "" then
tell application "Numbers" to tell document d_name to tell sheet s_name to tell (first table where selection range is not missing value)
tell selection range to set {top_left, bottom_right} to {name of first cell, name of last cell}
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 -
Need to extract only decimal numbers for a glob of text [SOLVED]
If you have a look at /dev/zero's thread here, you'll see that users have been posting the output of his script which are numbers that range from 2 to 5 decimal places. If I dump this entire thread to txt file, how can I:
1) Delete everything except for numbers of the following formats (where 'x' is a digit and '.' is a decimal point)?
2) Format the output to be one target per line?
x.xx
x.xxx
x.xxxx
x.xxxxx
xx.xx
xx.xxx
xx.xxxx
xx.xxxxx
I have experimented with some sed strings but am not making any traction. Perhaps your perl or awk ninjas have a good solution?
Here is the source file which was generated from a copy/paste of that thread into an empty text file: http://pastebin.com/ZkRFhFAr
Last edited by graysky (2012-12-21 11:19:05)Ooh, a challenge...
* 1 hour later *
#!/usr/bin/perl -an
@ary = grep /^\d{1,2}\.\d{2,5}$/, @F;
print join("\n", @ary) . "\n" if @ary;
Run as ./script.pl unixness_thread.txt
Not perfect, it grabs 10.04 which is an Ubuntu version in context, and 4.10 which is an Xfce version... but not too far off. Stick a "sort -n" on the end and knock off the obvious outliers and you'll be half there.
Edit -- just noticed it skips at least one number in parentheses: (8.73086). Was thinking the default splitting behavior would not be a problem but I was wrong. Not sure how to fix this but I think it can be done with -F.
Edit again -- changing the shebang as follows seems to work:
#!/usr/bin/perl -an -F/[^\d\.]/
Last edited by Trent (2012-12-21 01:55:08) -
How can i make the text go vertically in numbers
How can I make the text vertical in numbers? I have merged the cells and cannot find an option for making it go vertical as opposed to horizontal.
I already gave two tools to fit this kind of needs.
tip #1 :
--{code}
--[SCRIPT write_vertically]
Enregistrer le script en tant que Script : write_vertically.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications :Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Saisir dans une cellule le mot à écrire verticalement puis le sélectionner.
ATTENTION, il ne faut pas sélectionner la cellule mais le mot qui doit apparaitre surligné.
Aller au menu Scripts , choisir Numbers puis choisir “write_vertically”
Le script colle dans la cellule le mot apès avoir inséré un return entre tous les caractères.
Pour mon usage personnel j'associe un raccourci à ce script grace à FastScripts.
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: write_vertically.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
In a cell, type a word to write vertically then select it.
CAUTION, don’t select the cell but the word which must be highlighted.
Go to the Scripts Menu, choose Numbers, then choose “write_vertically”
The script insert in the cell the word after inserting a return between every characters.
For my own use, I link a shortcut to the script thank to FastScripts.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/12/17
2012/01/01 no longer use a local variable, use result
--=====
on run
Clear the clipboard *)
set the clipboard to ""
Copy the selection in the clipboard *)
my raccourci("Numbers", "c", "c")
Loop waiting that the clipboard is really filled *)
repeat
try
if (the clipboard as text) is not "" then exit repeat
on error
end try
end repeat
Extract the clipboard's content *)
the clipboard as text
Insert return between every characters *)
my recolle(every character of result, return)
Fill the clipboard with the edited string *)
set the clipboard to result
Paste in the cell *)
my raccourci("Numbers", "v", "cas")
end run
--=====
on recolle(l, d)
local oTIDs, t
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
--=====
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 ====
This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
It may be used to 'type' keyboard raccourcis if the third parameter describe the required modifier keys.
I changed its name « shortcut » to « raccourci » to get rid of a name conflict in Smile.
on raccourci(a, t, d)
local k
tell application a to activate
tell application "System Events" to tell application process a
set frontmost to true
try
t * 1
if d is "" then
key code t
else if d is "c" then
key code t using {command down}
else if d is "a" then
key code t using {option down}
else if d is "k" then
key code t using {control down}
else if d is "s" then
key code t using {shift down}
else if d is in {"ac", "ca"} then
key code t using {command down, option down}
else if d is in {"as", "sa"} then
key code t using {shift down, option down}
else if d is in {"sc", "cs"} then
key code t using {command down, shift down}
else if d is in {"kc", "ck"} then
key code t using {command down, control down}
else if d is in {"ks", "sk"} then
key code t using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
key code t using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
key code t using {command down, shift down, option down}
end if
on error
repeat with k in t
if d is "" then
keystroke (k as text)
else if d is "c" then
keystroke (k as text) using {command down}
else if d is "a" then
keystroke k using {option down}
else if d is "k" then
keystroke (k as text) using {control down}
else if d is "s" then
keystroke k using {shift down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"as", "sa"} then
keystroke (k as text) using {shift down, option down}
else if d is in {"sc", "cs"} then
keystroke (k as text) using {command down, shift down}
else if d is in {"kc", "ck"} then
keystroke (k as text) using {command down, control down}
else if d is in {"ks", "sk"} then
keystroke (k as text) using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
keystroke (k as text) using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
keystroke (k as text) using {command down, shift down, option down}
end if
end repeat
end try
end tell
end raccourci
--=====
--[/SCRIPT]
--{code}
tip #2 :
--{code}
--[SCRIPT rotate_cell_contents]
Enregistrer le script en tant que Script : rotate_cell_contents.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner une cellule dont le texte doit être tourné de 90 degrés.
Aller au menu Scripts , choisir Numbers puis choisir “rotate_cell_contents”
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: rotate_cell_contents.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell whose contents must be rotated for 90 degrees.
Go to the Scripts Menu, choose Numbers, then choose “rotate_cell_contents”
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/06/23
2011/06/26 -- No longer use an auxiliary text box. Now keep the text attributes.
2012/01/31 -- edited for Lion
--=====
on run
local dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2
local le_texte, la_largeur, la_hauteur, myNewDoc
my activateGUIscripting()
Extract properties of the source/target cell *)
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
set selection range to range (name of column colNum1 & name of row rowNum1)
end tell
Cut*)
my raccourci("Numbers", "x", "c")
Trigger Preview *)
tell application "System Events"
if "Preview" is not in (name of every application process) then launch application "Preview"
end tell
delay 0.2 -- required
New document from the clipboard *)
my raccourci("Preview", "n", "c")
Rotate to left *)
my raccourci("Preview", "l", "c")
Copy *)
my raccourci("Preview", "c", "c")
Quit *)
my raccourci("Preview", "q", "c")
(system attribute "sys2") < 7
if result then
Click the [Don't Save] button in the warning sheet *)
tell application "Preview" to activate
tell application "System Events" to tell application process "Preview" to tell window 1
name of buttons
repeat 50 times
delay 0.1
if exists sheet 1 then exit repeat
end repeat
tell sheet 1 to click button 2
end tell
end if
Back to Numbers *)
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
-- just reset the focus on the table
end tell
Paste in the cell *)
my raccourci("Numbers", "v", "c")
end run
--=====
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 -
How to find multiple keys in single cell using Numbers?
I'm trying to add functionality to one of my Numbers tables where want to check a single cell for multiple keywords from a list. The hole thing works perfectly fine in Excel but it behaves differently in Numbers.
The formula I am using is:
=IF(ISERROR(LOOKUP(2^15;FIND($E$2:$E$11;A2)));"not found";"found")
The following screenshots show that it correctly finds the keys in the cell when using Excel but not in Numbers. Although, it seems to work if the key is in the same row as the input cell.
Excel table using the formula I posted in the C column:
Numbers table using the formula I posted in the C column:
Would be really happy if somebody knows how I could accomplish that!
Cheers,
MaikIf you are working in Numbers you can do this efficiently with a small AppleScript without going back to Excel or clone. One click and you get the following result:
This script works with Numbers 2.3, which your screenshot suggests you are using. If you are using Numbers 3 it needs a very small adjustment.
This is the script:
--https://discussions.apple.com/thread/6315365?tstart=30
property inputCol : 1 --> col A, as in example
property resultCol : 3 --> col C, as in example
property keysCol : 5 --> col E, as in example
property targDoc : 1 --> 1 is front document; can change to "MyDocName"
property targSheet : 1 --> 1 is first sheet; can change to "MySheetName"
property targTable : 1 --> 1 is first table; can change to "MyTableName"
tell application "Numbers"
set t to document targDoc's sheet targSheet's table targTable
set keysList to t's column keysCol's cells's value
repeat with i from 2 to t's row count -- assumes 1 Header Row
set inputVal to t's row i's cell inputCol's value
if inputVal is not 0 then --skip blank cells; Numbers 2 reads blanks as 0
--check if Input matches a key:
if inputVal is in keysList then
set t's row i's cell resultCol's value to "found"
else
set t's row i's cell resultCol's value to "not found"
end if
--check if Input contains a key:
repeat with aKey in keysList
if inputVal contains aKey then set t's row i's cell resultCol's value to "found"
end repeat
end if
end repeat
end tell
--end of script
To run, copy into AppleScript Editor, change the properties if needed, and click the green triangle 'Run' botton.
SG
Maybe you are looking for
-
Problem in booking training programme in ESS
When an employee tries to book a Training programme and requests for attendance it is giving an error as "You have no authorization for the function or the object" in ESS & R/3. I am using the ITS service PV7I. Request to help in this issue. SB
-
Hi there, I use Firefox 19 with the option "Don't load tabs until selected" (in Options/Tabs). It's a neat option but when the tab reloads, it doesn't refresh the page but just reloads it at the state when the browser last closed. With Firefox 3.6, t
-
Uninstalling from OS X 10.5
Hi, I've just bought a new mac with OS X 10.5 and I'd like to uninstall iCal (since I have no use for it, it's taking up space and I'm a neat-freak) But when I try to delete it, there's one file that it can't remove - iCalDockExtra.bundle. After a bi
-
Purhase order output type ZYT3 going into error when triggeralong with ZMY1
Hi Experts, We am currently having this problem: While creating PO, we save 2 customized output types(ZMY1 & ZYT3 - 2 different print programs) together, with the same Dispatch time: Send immediately(when saving the application). But the ZYT3 will al
-
E75 - phot share broken after firmware update
I updated the firmware last weekend (1 August 2009), sorry don't know how to find the numbers. After update, I restored settings from backup and then discovered that I could not share a photo to Flickr or OVI from within the camera application. Later