I just discover this thread.
Here is a soluce with no temporary document.
--=====
on run
(*
Replace this read instruction by the code extracting your datas from MoneyWorks Express
*)
read file ((path to desktop as text) & "_20100729-152547.txt")
(*
Store the datas in the clipboard
*)
set the clipboard to result
(*
Activate GUI scripting to be able to paste
*)
my activateGUIscripting()
(*
Create a Numbers document from the Blank template
*)
set myNewDoc to my makeAnIworkDoc("Numbers")
tell application "Numbers" to tell document myNewDoc to tell sheet 1
delete table 1 (* It may be too large *)
make new table with properties {column count:2, row count:2}
tell table 1
remove row 1 (* remove the default header row *)
remove column 1 (* remove the default header column *)
end tell
end tell
my raccourci("Numbers", "v", "cas")
end run
--=====
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
--=====
(*
Creates a new iWork document from the Blank template and returns its name.
example:
set myNewDoc to my makeAnIworkDoc(theApp)
*)
on makeAnIworkDoc(the_app)
local maybe, path_to_the_App, nb_doc, doc_name
if the_app is "Pages" then
tell application "Pages"
set nb_doc to count of documents
make new document with properties {template name:item 1 of templates}
end tell -- Pages
else if the_app is "Numbers" then
tell application "System Events" to set maybe to the_app is in title of every application process
if not maybe then tell application theApp to activate
(*
I use this scheme because on my machine, iWork '09 isn't on the startup volume.
I have three volumes : one for 10.4.11, one for 10.5.8, one for shared items.
This way I'm OK with iWork's License which claims : one copy for one machine
*)
tell application "System Events"
set path_to_the_App to get application file of application process the_app
end tell
tell application "Numbers"
set nb_doc to count of documents
open ((path_to_the_App as text) & "Contents:Resources:Templates:Blank.nmbtemplate:")
end tell
else
if my parleAnglais(theApp) then
error "The application "" & the_app & "" is not accepted !"
else
error "l'application « " & the_app & " » n'est pas gérée !"
end if
end if
tell application the_app
repeat until (count of documents) > nb_doc
delay 0.1
end repeat
set doc_name to name of document 1
end tell -- the_App
return doc_name
end makeAnIworkDoc
--=====
on activateGUIscripting()
(* to be sure that 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
--=====
Yvan KOENIG (VALLAURIS, France) jeudi 29 juillet 2010 15:53:31