Quick and dirty, but this works (Office 2008)
tell application "Microsoft Entourage"
set contactList to {}
set lastContact to (count contacts)
repeat with thisContact from 1 to lastContact
set theContact to item thisContact of contacts
set end of contactList to (first name of theContact & " " & last name of theContact)
end repeat
set contactSelected to (choose from list contactList with prompt "Please select a contact." without multiple selections allowed) as text
if (contactSelected is not "False") then
display dialog contactSelected
end if
end tell
There are essentially two parts to the script: getting the contact names and presenting the information. Getting the contacts is easy because contacts
is a property of the application itself. Running this in 40+ contacts only takes a second.
Presenting the data and getting the selection isn't so obvious. The data to be presented has to be a string. Honestly, I forget why I have as text
dangling off the end, but I seem to remember that doing this was easier if everything was handled as a string of some kind. Once the selection has been verified—having "False" returned means the user clicked the cancel
button—you are then able to carry on with the string where I placed the display dialog
. Unfortunately, you don't get the row number or anything convenient like that. It just doesn't work that way, so you will have to do a bit of fudging to get back to the corresponding contact
object itself.
Add salt to taste...