Here is a little script that I use to plan an appointment for someone from an address book entry, then add it to Ical and finally add the appointment to a numbers document. It will probably be very useful for you, but you’ll need to change a lot of the parimeters.
property emptyString : ""
-------------------------------
try
set groupOrIndividual to button returned of (display dialog "Is this Contract for a group or an Individual :" buttons {"Group", "Individual"} default button 2)
if groupOrIndividual is "Individual" then
tell application "Address Book" to set unsortedList to name of people
set old_delims to text item delimiters
set text item delimiters to linefeed
set theList to paragraphs of (do shell script "echo " & quoted form of (unsortedList as string) & "| sort -d -f")
set text item delimiters to old_delims
set thePersonChosen to (choose from list theList with prompt " Please choose a Student :")
if thePersonChosen is false then return
set thePersonChosen to item 1 of thePersonChosen
else if groupOrIndividual is "Group" then
tell application "Address Book" to set unsortedList to name of every group
set old_delims to text item delimiters
set text item delimiters to linefeed
set theList to paragraphs of (do shell script "echo " & quoted form of (unsortedList as string) & "| sort -d -f")
set text item delimiters to old_delims
set thePersonChosen to (choose from list theList with prompt " Please choose a Group :")
if thePersonChosen is false then return
set thePersonChosen to item 1 of thePersonChosen
end if
on error
error "Failed to define if the contract is for a group or an individual"
end try
-------------------------------
try
tell application "Address Book"
set thePersonId to 1st person whose name is thePersonChosen
tell thePersonId
set thePersonFirstName to my computeValue(first name)
set thePersonLastName to my computeValue(last name)
set thePersonFullName to my computeValue(its name)
if thePersonFullName is emptyString then error
set {thePersonWorkAddressStreet, thePersonWorkAddressZip, thePersonWorkAddressVille, thePersonWorkAddressPays} to my getAddress(its addresses, "work")
set {thePersonHomeAddressStreet, thePersonHomeAddressZip, thePersonHomeAddressVille, thePersonHomeAddressPays} to my getAddress(its addresses, "home")
set thePersonCompany to my computeValue(organization)
set thePersonJob to my computeValue(job title)
set thePersondepartment to my computeValue(department)
set thePersonWorkPhone to my getPhone(phones, "work")
set thePersonMobile to my getPhone(phones, "Mobile")
set thePersonHomePhone to my getPhone(phones, "Home")
set thePersonWorkEmail to my getMail(emails, "work")
set thePersonHomeEmail to my getMail(emails, "home")
end tell
end tell
on error e
error "Failed to retrieve Student details" & return & e
end try
---------------------
set theStartDate to date (text returned of (display dialog "Please enter the start date and time for the event:" default answer "mardi 2 novembre 2010 22:00:00" buttons "OK" default button 1))
--------------------
set theEventLength to (text returned of (display dialog "Please enter the length in minutes for the event:" default answer "120" buttons "OK" default button 1))
------------
set theEventLocation to button returned of (display dialog "Where is the lesson going to take place :" buttons {"Organisation", "Student's home", "Home"} default button 1)
-----
on computeValue(val)
if val = missing value then return emptyString
return val
end computeValue
on getAddress(adr, lab)
tell application "Address Book"
repeat with anAddress in adr
if label of anAddress is lab then
return {my computeValue(street of anAddress), my computeValue(zip of anAddress), my computeValue(city of anAddress), my computeValue(country of anAddress)}
end if
end repeat
end tell
return {emptyString, emptyString, emptyString, emptyString}
end getAddress
on getPhone(pho, lab)
tell application "Address Book"
repeat with aPhone in pho
if label of aPhone is lab then
return my computeValue(value of aPhone)
end if
end repeat
end tell
return emptyString
end getPhone
on getMail(mail, lab)
tell application "Address Book"
repeat with aMail in mail
if label of aMail is lab then
return my computeValue(value of aMail)
end if
end repeat
end tell
return emptyString
end getMail
-----
tell application "iCal"
set theCalendarNames to title of every calendar --theCalendarNames is a list
end tell
set theCalenderChosen to (choose from list theCalendarNames with prompt " Please choose a calendar :") as string
-----------------------
if theEventLocation is "Organisation" then
tell application "iCal"
tell calendar theCalenderChosen
make new event at end with properties {description:thePersonCompany, summary:thePersonCompany & " " & thePersonLastName & " " & thePersonFirstName & " " & "leçon", location:thePersonWorkAddressStreet & " " & thePersonWorkAddressZip & " " & thePersonWorkAddressVille, start date:theStartDate, allday event:false, end date:theStartDate + theEventLength * minutes}
set theEvent to first event
set theEventID to uid of theEvent
end tell
end tell
else if theEventLocation is "Student's home" then
tell application "iCal"
tell calendar theCalenderChosen
make new event at end with properties {description:thePersonCompany, summary:thePersonCompany & " " & thePersonLastName & " " & thePersonFirstName & " " & "leçon", location:thePersonHomeAddressStreet & " " & thePersonHomeAddressZip & " " & thePersonHomeAddressVille, start date:theStartDate, allday event:false, end date:theStartDate + theEventLength * minutes}
set theEvent to first event
set theEventID to uid of theEvent
end tell
end tell
else if theEventLocation is "Home" then
tell application "iCal"
tell calendar theCalenderChosen
make new event at end with properties {description:thePersonCompany, summary:thePersonCompany & " " & thePersonLastName & " " & thePersonFirstName & " " & "leçon", location:"41 rue Marius Berliet,69008,Lyon", start date:theStartDate, allday event:false, end date:theStartDate + theEventLength * minutes}
set theEvent to first event
set theEventID to uid of theEvent
end tell
end tell
end if
tell application "Numbers"
activate
open ":Users:alan:Documents:speakUP:Suivi des heures:Suivi des Heures :Date des Leçons.numbers"
tell sheet 1 of document 1
tell table 1
tell last row
add row below
set value of cell 1 to thePersonCompany
set value of cell 2 to thePersonLastName
set value of cell 3 to thePersonFirstName
set value of cell 4 to theEventLocation
set value of cell 5 to theStartDate as string
set value of cell 6 to theStartDate as string
set value of cell 7 to theStartDate + theEventLength * minutes as string
set value of cell 8 to theEventLength / 60 as string
set value of cell 9 to theStartDate as string
set value of cell 10 to theEventID
set value of cell 11 to (current date) as string
end tell
end tell
end tell
end tell
tell application "Numbers"
activate
open ":Users:alan:Documents:speakUP:Suivi Clients" & ":" & thePersonCompany & ":" & thePersonLastName & thePersonFirstName & "FeuilleSignatures.numbers"
tell sheet 1 of document 1
tell table 1
tell last row
add row below
set value of cell 2 to theStartDate as string
set value of cell 3 to theEventLength / 60
end tell
end tell
end tell
end tell
Good luck