I am frustrated with the printing options in the Address Book, specifically for the Note field.
I thought applescript would be a perfect answer to this, because I could print the note field alone or pass it through to another applications such as TextEdit. It seems like a good way to get around the limited options in Address Book.
I can’t find any examples of scripts to do this. I have searched all over, and was hoping maybe someone else had done something similar. (Another script I would like is for printing out the description field in ical)
Some script I had hanging around to extract Address Book data. Hopefully this is not too long and rambling to be useful.
-- Searches Address Book for text in all vCard fields
-- Returns persons data in Dialog window
-- What are we looking for?
set theString to text returned of (display dialog "What are you looking for?" default answer "")
tell application "Address Book"
-- get all the people who have theString in their vCard
set thePeople to (get every person whose vcard contains theString)
-- repeat for everyone found
repeat with aPerson in thePeople
-- display persons record
set theID to id of aPerson
tell application "System Events" to open location "addressbook://" & theID
-- make an empty text string
-- we are going to add this persons details to it
set theData to ""
-- get person's name
set theName to name of aPerson
--set lastName to last name of aPerson
set theData to theData & theName
--get id of all addresses of person
set theAddresses to addresses of aPerson
-- cycle through (possible) addresses of record
repeat with anAddress in theAddresses
set theLabel to label of anAddress as text
set theStreet to street of anAddress as text
set theCity to city of anAddress as text
set theState to state of anAddress as text
set theCountry to country of anAddress as text
set theZip to zip of anAddress as text
set formatAddress to theLabel & return & theStreet & return & theCity & return & theState & return & theCountry & return & theZip
set theData to theData & return & return & formatAddress
end repeat
-- add line break
set theData to theData & return
--get IDs for all phone numbers of person
set thePhones to phones of aPerson
--cycle though iDs and extract values
repeat with aPhone in thePhones
set thePhone to value of aPhone as text
set theData to theData & return & thePhone
end repeat
--get IDs for all email addresses of person
set theEmails to emails of aPerson
--cycle though iDs and extract values
repeat with anEmail in theEmails
set theEmail to value of anEmail as text
set theData to theData & return & theEmail
end repeat
set theData to theData & return & return
--Get the note data
set theNote to note of aPerson
set theData to theData & theNote
-- display all data on person
display dialog theData
-- Or quick 'n' dirty way (no note)
(*
set theCard to vcard of aPerson
display dialog theCard
*)
end repeat
end tell