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



However, there is a trick to it that works almost every time: run a script every 1 minute from a repeating Schedule. The script can check for all sorts of things, in particular whether there is a new draft window (new message window) in the front, and do nothing otherwise, but do whatever you need when it finds one and checks for other conditions. Since it should almost always take you more than a minute to write a message (and the average will actually be 30 seconds before the next schedule run), it can catch your message before you've finished writing it and add what you need. The next two scripts take advantage of that fact. [Ed. Note: be careful with this one, and bear the timing in mind. For short messages, you can certainly compose a message quickly enough and be out of sync with the scheduler. If you rely on this method, check your message before sending to make sure your script had a chance to run!]

Attach a vCard

Entourage has no setting to attach your vCard to outgoing messages. You can drag your "Me" contact from the address book to the message every time, but that soon becomes tedious. Instead run this script, which uses a cool technique, plus AppleScript's read/write commands and some Finder scripting to update your vCard, then attach it. If you're one of those people who likes to send your vCard on every message (well, I know there are people who do), set the script to run from a repeating schedule every 1 minute.

 

tell application "Microsoft Entourage"

     set MUDpath to (path to MUD) as Unicode text

     set meContact to me contact

     set vcInfo to vcard data of meContact

     set myname to name of meContact

end tell

 

set pathName to (MUDpath & myname & ".vcf") as Unicode text

 

try

     set f to open for access file pathName with write permission

     --will create a new one or update every time

     set eof f to 0

     write vcInfo to f

     close access f

    

     tell application "Finder"

          set creator type of file pathName to "OPIM"

          set file type of file pathName to "vCrd"

     end tell

    

     set theVcard to alias pathName

    

on error errMsg number errNum

     try

          close access f

     end try

     beep 2

     return

end try

 

tell application "Microsoft Entourage"

     try

          if class of window 1 ­ draft window then error number -128



< 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