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



(In fact, we ought to be able to just get the address property of each recipient of the original message and just make that the content for the new group entry, without even needing to parse it into its own separate address and display name properties, other than for checking for duplication.)

Well, this is a bug in Entourage's AppleScript. When making a new group entry, you have to use that text format of "Joe Blow <jblow@aol.com>", or simply "jblow@aol.com" if there's no display name, rather than the proper record structure for content of {address:"jblow@aol.com", display name:"Joe Blow"}.

This bug has been in place since Entourage existed (and before that in Outlook Express too); at this point if it were fixed it would break too many scripts. So it will never be fixed – you've just got to learn it. It's not documented anywhere but here (it really should be mentioned in the dictionary now that there's no longer any limit on dictionary entry description length, but that's only since OS 10.3, newer than Entourage 2004).

Calendar Events and Tasks

Make New Event / Open an Event or Task

Making a new event (the AppleScript class for what's usually called "calendar event") is just the same as making a new contact, including consideration of the new multiple calendars if you have an Exchange account, but with fewer properties available.

tell application "Microsoft Entourage"

   set newEvent to make new event with properties {subject:¬

      "New Event", start time:¬

      date "1/8/07 10 am", end time:¬

      date "1/8/07 11 am", remind time:15, location:¬

      "Macworld SF", content:"Some notes here." category:¬

      {category "Recreation"}}

end tell

See how you can enter the format for short dates on your computer (mine is US) for the start time and end time properties, and Script Editor compiles them to date objects:

tell application "Microsoft Entourage"

     set newEvent to make new event with properties {subject:¬

          "New Event", start time:¬

          date "Monday, January 8, 2007 10:00:00 AM", end time:¬

          date "Monday, January 8, 2007 11:00:00 AM", remind time:15, location:¬

          "Macworld SF", content:"Some notes here.", category:¬

          {category "Recreation"}}

end tell

There are a number of properties in the dictionary available just for Exchange events (not used above), and one property (to recipients) used for making invitations. Be aware that if you include to recipients, the invitation gets sent off as an email message the instant the event is made!

If you set all day event to true, the start time needs to be to midnight , and the end time to midnight of the next day (or several days later if making a multi-day event: always the midnight just after the last day of the event). Entourage should put it right if you get it wrong, but maybe not on quite the day you expect, so it's better to get it right.

To make a recurring event (recurring:true), you'd need to get an appropriate recurrence string off an event of the same recurrence pattern that you've made in the UI. It's far too complicated to learn all the rules (there is an RFC somewhere that details them: it's called an "iCal recurrence".) It‘s probably best to avoid recurrence unless you can just take one from an existing event and set that.

Opening an event (or task or note) is just the same as opening anything else in the Entourage database. Just identify the event and open it. Read the Open Existing Contact section earlier in this chapter. The main difference is that you will often – usually – have more than one event with the same name, so getting it by name only (event "Meeting") is not good enough: it will only get the first one created with that name.

You need a whose clause that filters on both the name and a time "slot". It's usually not a good idea to insist on an exact time, just in case you've got it not quite right: better would be to specify a whole day or week:

tell application "Microsoft Entourage"

     set theEvent to first event whose subject is "My Event" and ¬

          start time ³ date "Monday, January 8, 2007 12:00:00 AM" and ¬

          start time < date "Tuesday, January 9, 2007 12:00:00 AM"



< 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