• MacTech Network:
  • Tech Support
  • |
  • MacForge.net
  • |
  • Apple News
  • |
  • Register Domains
  • |
  • SSL Certificates
  • |
  • iPod Deals
  • |
  • Mac Deals
  • |
  • Mac Book Shelf

MAC TECH

  • Home
  • Magazine
    • About MacTech in Print
    • Issue Table of Contents
    • Subscribe
    • Risk Free Sample
    • Back Issues
    • MacTech DVD
  • Archives
    • MacTech Print Archives
    • MacMod
    • MacTutor
    • FrameWorks
    • develop
  • Forums
  • News
    • MacTech News
    • MacTech Blog
    • MacTech Reviews and KoolTools
    • Whitepapers, Screencasts, Videos and Books
    • News Scanner
    • Rumors Scanner
    • Documentation Scanner
    • Submit News or PR
    • MacTech News List
  • Store
  • Apple Expo
    • by Category
    • by Company
    • by Product
  • Job Board
  • Editorial
    • Submit News or PR
    • Writer's Kit
    • Editorial Staff
    • Editorial Calendar
  • Advertising
    • Benefits of MacTech
    • Mechanicals and Submission
    • Dates and Deadlines
    • Submit Apple Expo Entry
  • User
    • Register for Ongoing Raffles
    • Register new user
    • Edit User Settings
    • Logout
  • Contact
    • Customer Service
    • Webmaster Feedback
    • Submit News or PR
    • Suggest an article
  • Connect Tools
    • MacTech Live Podcast
    • RSS Feeds
    • Twitter

Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition

Introduction  |  Table of Contents

Page Prev and Page Next buttons at bottom of the page.

Would you like a hard copy
or PDF of this Guide?

You can get a hard copy sent to you
AND download a PDF now ($19.95)
, or

... just download a PDF ($9.95).

Either way, you get a complimentary
MacTech Magazine Subscription

courtesy of the
Microsoft Mac Business Unit


 

  Magazine Reg. Price:  $50.00 value  
  Guide Reg. Price:  $40.00 value  
  You Save:  over $80.00!  

April, 2007
Page 124



You need to set variables (email1, email2) to the email address elements in order to select one of them as default email address. (By default, the first one made will be.)

There is a lot more you can set for contact, or can change on an existing contact – have a go. Almost all properties are text type, but note that children is a list. Then there are a few properties that are records like the home address made above, and a few that are dates, namely anniversary, birthday and the two custom date fields.

Open an Existing Contact

Entourage keeps a database for each identity. All its elements are in that database, not in separate files on your computer like Word documents. That makes it much easier to refer to them, whether to open them or to modify them. They are almost always obtainable by ID (which you usually won‘t know), by index – generally in order of creation (which you won‘t know), by name (which you will know), or by whose filter (which you can devise).

The same conditions apply to referring to contacts as to making them, with regard to location. If you do not have an Exchange account, you can just refer to contact "Joe A. Blow" – of no location. (You do have to get the name exactly right if you refer by name.) You can do the same if he is in your default address book, even if you have Exchange with all its extra address books. However, this does not work to reference the contact:

   contact "Joe A. Blow" of address book 1

(I hope this is made to work for a later version. It seems to me to be a bug.) You cannot refer by name to a contact in a particular specified address book. But this works, though slower:

first contact of address book 1 whose name is "Joe A. Blow"

So to open that contact into its tabbed contact window, just preface any valid expression for contact with the command open:

tell application "Microsoft Entourage"

     open contact "Joe A. Blow" -- if in default address book

     -- or if not:

     open (first contact of address book 1 whose name is "Joe A. Blow")

end tell

Invert Contact Names

Occasionally you'll find that you've created a contact via 'Add to Address Book' from a message where the sender was using an email client that puts the last name before the first name, like so: LastName, FirstName. Worse, you may have imported hundreds of contacts of this type from some other program. Entourage does not understand this format and puts the LastName, plus the comma, into the First Name field, and LastName into the First Name field, and then sorts by the (real) FirstName placed last – a mess. A simple script will put that right:

 

tell application "Microsoft Entourage"

     set backToFronts to every contact whose ¬

          first name ends with ","

     repeat with theContact in backToFronts

          tell theContact

              set {realFirst, realLast} to {last name, first name}

              try

                   set realLast to text 1 thru -2 of realLast

              on error

                   set realLast to ""

              end try

              set {first name, last name} to {realFirst, realLast}

          end tell

     end repeat



< Previous Page Next Page>
 
MacTech Only Search:
Community Search:

 
 
 

 
 
 
 
 
  • SPREAD THE WORD:
  • Slashdot
  • Digg
  • Del.icio.us
  • Reddit
  • Newsvine
  • Generate a short URL for this page:



MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797
MacTech is a registered trademark of Xplain Corporation. Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, Apple Expo, MacTech Central, MacTech Domains, MacNews, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.
All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
 
Nov. 20: Take Control of Syncing Data in Sow Leopard' released
Nov. 19: Cocktail 4.5 (Leopard Edition) released
Nov. 19: macProVideo offers new Cubase tutorials
Nov. 18: S Stardom anounces Safe Capsule, a companion piece for Apple's
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live