Here is a script doing the entire job with a single call.
--{code}
--[SCRIPT table_to_html]
(*
Enregistrer le script en tant que Script : table_to_html.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 table dans le panneau des vignettes d'un document Numbers.
Aller au menu Scripts , choisir Numbers puis choisir “table_to_html”
Le script copie la table,
la colle dans un nouveau document RTF de TextEdit,
enregistre celui-ci au format html,
ouvre ce dernier avec Safari
et enfin affiche le source html.
--=====
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: table_to_html.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 table in the thumbnail pane of a Numbers document.
Go to the Scripts Menu, choose Numbers, then choose “table_to_html”
The script copy the table
paste in a new TextEdit RTTF document
save this one as Html
open it in Safari
and at last reveal the Html source.
--=====
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/01
*)
--=====
on run
local nom_Tedit, menuName, path_html
my activateGUIscripting()
(*
copy the selected table
*)
my raccourci("Numbers", "c", "c")
(*
create an unique name
*)
set nom_Tedit to do shell script "date +_%Y%m%d_%H%M%S"
(*
create a blank TextEdit document
*)
tell application "TextEdit"
makenewdocumentwith properties {name:nom_Tedit}
end tell
(*
grab the name of the menu item "convert to format wxyk"
*)
set menuName to my get_menu_name("TextEdit", 5, 4) (* Format > Convertir au format xxx *)
(*
if the menu name contains RTF, trigger it
*)
if menuName contains "RTF" then my raccourci("TextEdit", "t", "cs")
(*
paste in the TextEdit RTF document
*)
my raccourci("TextEdit", "v", "c")
(*
save as html
*)
my save_as_html("TextEdit")
(*
grab the UNIX full path of the new html file
and close it.
*)
tell application "TextEdit"
set path_html to path of document 1
closedocument 1
end tell
(*
open the html file in Safari
*)
tell application "Safari"
openpath_html
end tell
(*
open the source
*)
my raccourci("Safari", "u", "ca")
end run
--=====
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 applicationa to activate
tell application "System Events" to tell application process a
set frontmost to true
try
t * 1
if d is "" then
key codet
else if d is "c" then
key codetusing {command down}
else if d is "a" then
key codetusing {option down}
else if d is "k" then
key codetusing {control down}
else if d is "s" then
key codetusing {shift down}
else if d is in {"ac", "ca"} then
key codetusing {command down, option down}
else if d is in {"as", "sa"} then
key codetusing {shift down, option down}
else if d is in {"sc", "cs"} then
key codetusing {command down, shift down}
else if d is in {"kc", "ck"} then
key codetusing {command down, control down}
else if d is in {"ks", "sk"} then
key codetusing {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
key codetusing {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
key codetusing {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
keystrokekusing {option down}
else if d is "k" then
keystroke (k as text) using {control down}
else if d is "s" then
keystrokekusing {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
--=====
on save_as_html(theApp)
tell applicationtheApp to activate
tell application "System Events" to tell process theApp
keystroke "s" using {command down, shift down}
repeat until exists sheet 1 of window 1
delay 0.2
end repeat
tell sheet 1 of window 1
tell first pop up button of group 1 of group 1
click
clickmenu item 3 of menu 1
end tell
keystrokereturn
end tell
end tell
end save_as_html
--=====
(*
my get_menu_name("TextEdit", 5, 4) (* Format > FileName *)
*)
on get_menu_name(theApp, mt, mi)
tell applicationtheApp to activate
tell application "System Events" to tell process theApp to tell menu bar 1
get name of menu bar items
(*{
01 - "Apple",
02 - "TextEdit",
03 - "Fichier",
04 - "Édition",
05 - "Format",
06 - "Fenêtre",
07 - "Aide"}
*)
get name of menu bar itemmt
-- {"Format"}
tell menu bar item mt to tell menu 1
get name of menu items
(* {
01 - "Police",
02 - "Texte",
03 - missing value,
04 - "Convertir au format RTF",
05 - "Empêcher les modifications",
06 - "Adapter à la page",
07 - "Permettre la césure",
08 - missing value,
09 - "Liste…",
10 - "Tableau…"}
*)
set mName to get name of menu item mi
(*
{"Convertir au format RTF"}
or
{"Convertir au format Texte"}
*)
end tell -- menu bar item
end tell -- System Events
return mName
end get_menu_name
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) mercredi 1 juin 2011 21:36:54
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !