• 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 128



Finally, the script links the task to the contact and opens the task, i.e., its window – which is precisely why we set a variable theTask when making it, to be able to follow up with the two final commands to link and open it. You can then adjust the due date and reminder time if you wish. If you think you might use this script in future, save it to Entourage Script Menu Items folder and add a keyboard shortcut such as \cmC (control-command-C) to the end of its name.

Copy to a Custom Field (Contacts)

If you export Entourage contacts to a text file via File/Export/Local contacts, you will have discovered that it does not export the Category information for the contacts. There are times, for example if you then import the text file into Excel, when you really need to have the Category information. One way to get it is to use a script to enter the category names in one of Entourage's custom fields. There are 8 of those, and you usually won‘t need all of them. Let's say you want to enter the Category information in Custom 8 field.

You probably should rename that to "Categories"; of course that's easy to do in the address book (open any contact click on the Custom 8 label and choose Edit Label) but it's also possible to do that by script, which we will do. Note that contacts (and other Entourage objects) can have more than one category: that's why category property of contact (and of event, task, note, group, etc.) is a list of categories.

For our script we'll need to use a separator when converting the list of category names to text: here we'll use a comma but you could use any other separator, e.g., a semicolon, or slash, if you prefer. The way to do this is to set AppleScript's text item delimiters to the chosen separator character (within list braces), and then coerce the list to text.

You should then reset the delimiters to whatever they were, namely the default "" in most cases, afterwards, because the delimiters are retained for the entire session (i.e. until Quit) of whatever application is running the script (Script Editor, Entourage if run from its menu, System Events if run from the system menu, etc.) and might mess up other scripts if they are not rigorous (as they should be) about setting delimiters before coercing lists to text.

Here is the script:

tell application "Microsoft Entourage"

     set custom field eight name of address book 1 to "Categories"

     set categoryContacts to every contact ¬

where its category ­ {}

     repeat with i from 1 to (count categoryContacts)

          set theContact to item i of my categoryContacts

          set catNames to {}

          set theCats to category of theContact

          repeat with j from 1 to count theCats

              set theCategory to item j of theCats

              set end of catNames to name of theCategory

          end repeat

          set AppleScript's text item delimiters to {", "}

          set catNames to catNames as Unicode text

          set AppleScript's text item delimiters to {""}

          set custom field eight of theContact to catNames

     end repeat

     beep

     display dialog "All done!" buttons {"OK"} ¬

          default button "OK" with icon 1



< 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