• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AddressBook / TextEdit contact printout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AddressBook / TextEdit contact printout


  • Subject: AddressBook / TextEdit contact printout
  • From: Michael Ghilissen <email@hidden>
  • Date: Mon, 1 Dec 2008 08:53:38 -0500

Hi, I am trying to print selected AB contacts in TextEdit and I am running into difficulties with the text formatting. 

Color changes and italicizing are not carried out across all the paragraphs, with no apparent reasons including foul invisible characters. Any idea about where to look for a solution or any suggestion as how to present the data in a more efficient way?

Here is the script:

-- Warning: it is wise to export a copy of the AddressBook (File/Export) before using this script

tell application "Address Book"
set thePerson to get selection as list
repeat with i from 1 to count thePerson


set theFirstname to ""
set theLastname to ""
set theJobtitle to ""
set theOrganization to ""
set theEmails to {}
set thePhones to {}
set theURLS to {}
set theAddresses to {}


set theFirstname to (first name of item i of thePerson)
set theLastname to (last name of item i of thePerson)
set theJobtitle to (job title of item i of thePerson)
set theOrganization to (organization of item i of thePerson)
repeat with theRef in (get every email of item i of thePerson)
set end of theEmails to {label, value} of theRef
end repeat
repeat with theRef in (get every phone of item i of thePerson)
set end of thePhones to {label, value} of theRef
end repeat
repeat with theRef in (get every url of item i of thePerson)
set end of theURLS to {label, value} of theRef
end repeat
repeat with theRef in (get every address of item i of thePerson)
set end of theAddresses to {label, street, city, state, zip, country} of theRef
end repeat
set theNote to (note of item i of thePerson)


-- convert list to text
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "  "
set theEmails to theEmails as text
set thePhones to thePhones as text
set theURLS to theURLS as text
set theAddresses to theAddresses as text
set AppleScript's text item delimiters to old_delim


tell application "TextEdit"
activate
set E to make new document at end of documents with properties {name:"AB Contact"}
tell E
set its text to ("AddressBook Contact" & return & return & return & ¬
"Name      " & theFirstname & " " & theLastname & return & ¬
"Company " & theOrganization & return & return & ¬
"Address   " & theAddresses & return & return & ¬
"Website   " & theURLS & return & ¬
"Email      " & theEmails & return & return & ¬
"Phone     " & thePhones & return & return & ¬
"Note       " & theNote & return) as text


repeat with k in {"Name", "Company", "Address", "Website", "Email", "Phone", "Note"}
set (the color of every word where it is k) to {38000, 38000, 38000}
end repeat


set (the word of every word where it is "missing") to ""
set (the word of every word where it is "value") to ""


set the font to "Helvetica"
set the size to 14
set the font of paragraph 1 to "Helvetica Bold"
repeat with l in {"work", "home", "main", "fax", "mobile"}
set (the font of every word where it is l) to "Helvetica Italic"
end repeat
end tell
print document "AB Contact"
close document "AB Contact" saving no
end tell
end repeat
end tell

Thanks for your help,

Michael Ghilissen
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Next by Date: Re: AppleScript-Users Digest, Vol 5, Issue 634
  • Next by thread: Re: AppleScript-Users Digest, Vol 5, Issue 634
  • Index(es):
    • Date
    • Thread