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



6. Entourage

An Introduction to Entourage Scripting (No VBA Anywhere in Sight)

Entourage?

Why Entourage? You're probably already aware that Entourage, although a fully-fledged and important application in the Microsoft Office Mac suite, has never had VBA in the first place, so there's nothing to convert. Although Entourage corresponds quite closely to the role played by Outlook in Office Windows, it was never a port of Outlook to the Mac in the way that Word, Excel and PowerPoint are. (Actually, Word, Excel and PowerPoint were all originally on the Mac and in their earliest versions could be seen as being ported from Mac to Windows, but that's a story for another day. In their current incarnations, it works the other way around, with a Mac-oriented UI, modifications, adaptations, and Mac-specific features being added after receiving the shared part of the code – the core features – from the current Windows versions.)

Entourage, however, has always had an excellent AppleScript implementation. Now that you're becoming proficient in AppleScript, you suddenly have a whole new world open to you – actually, many new worlds; as many as there are AppleScriptable applications on the Mac.

Entourage shares many cross-Office features with the other Office applications, and has many useful features of its own. This article will give you just a short introduction to Entourage scripting as an example of how your AppleScript skills can now be extended and put to good use. In addition, a few useful techniques and implementations, plus one or two pitfalls to avoid, are described here that are not documented anywhere in the Entourage AppleScript dictionary nor anywhere else.

Finally, since Entourage has been scriptable for so long, there are already many scripts available for it – many can be found at MacScripter: <http://scriptbuilders.net>. You might find some there that already do exactly what you need. You‘ll also find a very large collection of open-source scripts from which to learn.

Entourage has a dictionary built on top of (and expanded from) the old Outlook Express Mac from Classic OS 8 (or maybe even 7.5) days. On the one hand, most of its syntax is a lot simpler and clearer than the other, rather contrived set from the other Office applications, and really does read more like English. On the other hand, the oldest part of the dictionary (non-Exchange email) is derived from the old OS 7 Apple Mail Suite, which had a few really odd quirks. The very newest parts of the dictionary (Exchange functionality) have a few quirks of their own.

Since Entourage does so many types of things, and makes so many different kinds of objects, this chapter will deal first with Email Messages, then Contacts & Groups, then Calendar Events & Tasks. (Notes will have to look after themselves.) Some scripts will overlap areas. We‘ll start by linking from the previous chapters – sending a document you made in Word, Excel, or PowerPoint as an attachment to an email message.

(All scripts in this chapter are my own: some published, some unpublished until now.)

Email: Make and Send a Message with an Attachment

You've just saved a document in Word, Excel or PowerPoint. Now you want to send it as an email attachment to someone. That's quite simple – just go to File/Send To/Mail Recipient (As Attachment). That brings up an empty email window in Entourage with the document already in place as an attachment. You then fill in the recipients, subject, write your message, and send. But if you regularly need to send such messages with attachments, every day, many times, always to the same recipients, this is going to get tedious very fast. Instead, write a script telling Entourage to do it all for you in a flash.

If you want to write a different message each time, the script can just switch you to Entourage with the attachment in place, the recipients already filled in, and the subject too, if you wish, and maybe a salutation ready for you to write the rest of the message. But if the message text can be "potted" as well, you can simply have the message prepared and sent off in the background without ever switching away from the application you're working in. We‘ll look at both cases.

The first step, in both cases, is to check that the document is saved – or save it – and to get its file path. This one step needs to be done in the application you're working from, and will be slightly different depending on whether that's Word, Excel or PowerPoint.

In Word:

tell application "Microsoft Word"

     try

          set frontDoc to active document

          save frontDoc



< 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