Below is my appleworks applescript macro to automatically print
envelopes.
A rewrite of a AW5 macro that was extremely popular with my users.
However,
despite Iots of fiddling I cant get the PROPERTY bitty to work. It
either
always prompts for the template or never prompts and errors.
Is anybody able to tell me what is going wrong in the first if
statement?
Also what is best practice for writing AW 6 macros, do I still need
the
"tell application" and "activate" if I cam being called from within
AW? Any
other pointers or suggestions gratefully accepted.
property envelopedoc : ""
if envelopedoc is equal to "" or not (exists file envelopedoc) then
set envelopedoc to choose file with prompt "Please select the
envelope template to use"
end if
tell application "AppleWorks 6.2.9"
activate
try
set selectedText to selection of front do***ent
if length of selectedText is less than 20 then
say "Nothing worth printing"
return
end if
set the clipboard to selectedText
open envelopedoc
set envelopename to name of front do***ent
select do***ent envelopename
paste
select text of do***ent envelopename
set font of selection to "Helvetica"
set size of selection to 15
print front do***ent with print dialog
close do***ent envelopename without saving
on error theerror
close do***ent envelopename without saving
display dialog theerror
display dialog "Unable to print envelope." \
buttons {"OK"} default button "OK" with icon 0
end try
end tell
Regards Fergus.