MacTech Network:   MacForge.net  |  Computer Memory  |  Register Domains  |  Printer Supplies  |  Cables  |  iPod Deals  |  Mac Deals  |  Mac Book Shelf


  MacTech Magazine

The journal of Macintosh technology

 
 
StuffIt

Magazine In Print
  About MacTech  
  Home Page  
  Subscribe  
  Archives DVD  
  Submit News  
  Submit a Tip!  
  Get a copy of MacTech RISK FREE  
Google
Entire Web
mactech.com
Mac Community
More...
MacTech Central
  by Category  
  by Company  
  by Product  
MacTech News
  MacTech News  
  Previous News  
  MacTech RSS  
Article Archives
  Show Indices  
  by Volume  
  by Author  
  Source Code FTP  
Inside MacTech
  Writer's Kit  
  Editorial Staff  
  Editorial Calendar  
  Back Issues  
  Advertising  
Contact Us
  Customer Service  
  MacTech Store  
  Legal/Disclaimers  
  Webmaster Feedback  

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



 


Click here to find out more about our best subscription bundle deal ever!
2 years of the magazine, and the all new MacTech DVD ... at 70% off!



Click on the cover to
see this month's issue!

TRIAL SUBSCRIPTION
Get a RISK-FREE subscription to the only technical Mac magazine!
 
 


MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797

Register Low Cost (ok dirt cheap!) Domain Names in the MacTech Domain Store. As low as $1.99!
Save on brand compatible and name brank ink jet and laser supplies.
Save on long distance * Upgrade your Computer
Movies with No Late Fees!

See local info about Westlake Village
SJ * BRJ * BJ * OJ * NITS
Staff Site Links



All contents are Copyright 1984-2007 by Xplain Corporation. All rights reserved.

MacTech is a registered trademark of Xplain Corporation. Xplain, Video Depot, Movie Depot, Palm OS Depot, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, NetProLive, JavaTech, WebTech, BeTech, LinuxTech, Apple Expo, MacTech Central 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.