Title: Re: script ideas
On 10/19/00 6:09 AM, "Rick Johnson" <[EMAIL PROTECTED]> wrote:
> 4) Fix Default Address: 99% of my addresses are home addresses, yet the
> work address is the default. A script to check for a home address and set
> it to the default, if found, would be very useful.
Here's this one: you can either select certain contacts and/or Groups (thanks to Bruce yesterday), or apply to all contacts in the Address Book. You also choose either way" to make Home or Work the default postal address for the selected or all contacts. the criterion is if there's a street address listed. (I should have added an "All done!" alert to the last script as I did here. You can copy this one, with its preceding "beep 2" in to the other script at the end, just before the "end tell" there. With these slow scripts, it's a good idea, so you can go away and can back later to see if it's done or not.)
----------------SET DEFAULT POSTAL ADDRESS-----------------------
on run
tell application "Microsoft Entourage"
display dialog "Would you like the" & return & return & "� Home postal address" & return & return & "� Work postal address" & return & return & "to be set as default postal address?" buttons {"Work", "Home"} with icon 1
set whichAddress to button returned of result
display dialog "And should this be applied to" & return & return & "� All contacts in the Address Book" & return & return & "� Contacts and/or contact members of Groups you have selected in the Address Book?" buttons {"Selected", "All"} with icon 1
set howMany to button returned of result
if howMany = "Selection" then
try
set theSelection to the selection -- if closed contact booklet in front, will error
if (class of theSelection � list) or ({class of item 1 of theSelection} is not in {contact, group}) then error number -128 -- to enforce 'on error' if string, folder, address book, etc.
on error
beep
display dialog "You need to select at least one contact in the Address Book first." with icon 0
return
end try
set theList to {}
set {ods, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {", "}}
repeat with theContact in theSelection
if class of theContact = contact then -- avoid groups selected in error
set end of theList to theContact
else if class of theContact = group then
repeat with grpMember in (every group entry of theContact)
set {dName, theAddress} to {display name, address} of content of grpMember
set grpContacts to find theAddress
if (count grpContacts) = 1 then
set grpContact to item 1 of grpContacts -- don't worry about display name, could be company, etc.
else if grpContacts � {} then
repeat with aContact in grpContacts
if dName = name of aContact then
set grpContact to aContact
exit repeat
else
set grpContact to "" -- define
end if
end repeat
else -- if not a Contact
set grpContact to "" -- define
end if
if grpContact � "" then set end of theList to grpContact
end repeat
end if
end repeat
else -- all contacts
set theList to every contact
end if
repeat with theContact in theList
if whichAddress = "Home" then
set thePostal to theContact's home address
set def to home
else
set thePostal to theContact's business address
set def to work
end if
if street address of thePostal � "" then
set default postal address of theContact to def
end if
end repeat
beep 2
display dialog "All done!" with icon 1
end tell
end run
------------------END SCRIPT ---------------------------------
--
Paul Berkowitz
- Re: script ideas Paul Berkowitz
- Re: script ideas Rick Johnson
- Re: script ideas Allen Watson
- Re: script ideas Paul Berkowitz
- Re: script ideas Rick Johnson
- Re: script ideas Allen Watson
- Re: script ideas Michael W. Wellman
- Re: script ideas [LONG SCRIPT] Paul Berkowitz
- Re: script ideas [LONG SCRIPT] Rick Johnson
- Re: script ideas [LONG SCRIPT] Paul Berkowitz
- Re: script ideas -ALERT! Paul Berkowitz
- Re: script ideas -ALERT! Paul Berkowitz
- Re: script ideas -ALERT! - try this one Paul Berkowitz
- Re: script ideas Paul Berkowitz
- Re: script ideas Michael W. Wellman
