property myPath : ""
using terms from application "Address Book"
on action property
return "address"
end action property
on action title for p with v
return "Print envelope"
end action title
on should enable action for p with v
return true
end should enable action
on perform action for p with v
try
set myPath to (path to me as string)
set {Line1, Line2, Line3, Line4} to {"", "", "", ""}
if name of p is not missing value then set Line1 to ¬
name of p
if street of v is not missing value then set Line2 to ¬
street of v
if city of v is not missing value then set Line3 to ¬
city of v
if state of v is not missing value then set Line3 to ¬
Line3 & ", " & state of v
if zip of v is not missing value then set Line3 to ¬
Line3 & " " & zip of v & " "
tell application "Microsoft Word"
activate
set NewDoc to create new document
print out envelope ¬
envelope object of NewDoc ¬
address Line1 & return & Line2 & return & Line3
close NewDoc saving no
end tell
on error errm number errn
display dialog "Error in " & myPath & ": " & return & ¬
errm & " #" & errn & "."
end try
end perform action
end using terms from