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



                   (remove -- from next line)

              *)

              --delete theEvent

             

          end repeat -- 1 times

     end repeat

    

     if (count theEvents) = 1 then open newTask

    

end tell

Regarding the section in the middle concerning recurring events and tasks: you might have selected an event in the current week or month of the calendar that is a recurring event whose first occurrence may have been weeks or years ago. You do not want a recurring task with a due date of two years or two weeks ago, complete with a reminder for past overdue occurrences, but rather one whose first occurrence is the next occurrence. (Particularly because the format for recurring tasks is that there is simply one incomplete task at a time: the next occurrence is not created by Entourage until you complete the current one, so you would see only the ancient due date of the original occurrence's start time.)

The script uses a great command introduced in Entourage 2004 – calculate recurring dates for – which needs from and to framing dates: we need to start with the original start time and stop a year from now, which should include the next occurrence even if it's a yearly event such as a birthday. We run through all the dates until we hit the first one in the future ( > now) and that's our next occurrence, so we make that date the new theStartDate which will be set as the due date for the task.

The remind time property of event is – like the settings in the UI – an integer representing the number of minutes before the start time of the event. But the remind date and time property of task is a date object representing a precise date and time (in the UI arrived at via a mini-calendar and a clock), no doubt because the due date is just a date without a time component.

In any case you have to do the calculation of subtracting 60 times the event's reminder (to convert the minutes into seconds) from the event's start time to get the date-time form for the task's reminder, and also use another variable to set the time of the event's start time to 0 (i.e., midnight) to get the right form for the due date of the task.

There is a line that adds any Location field info from the event to the task's title in parentheses – if you don‘t want this, remove the line (continued by ¬ onto a second line below it. so remove that too).

Finally, the script needs to check again whether the event was a recurring task: if not, then you must completely omit any mention of recurring and recurrence properties (even though recurring is false!) when making the new task, or it will be turned into a recurring task with the default recurrence pattern of "every day"! So you need an if block to cover the two possibilities.

There is an option line if you now want to delete the original event once the task is made: if so uncomment (remove the double-dash -- before) the delete line. If you selected only one event (count theEvents = 1), the script opens it for you to make any adjustments.

Update Incomplete Tasks

Here's a tiny script that will update all of (today's) incomplete tasks – the ones you never managed to finish, and will give them a new Due Date of tomorrow and a new Reminder at the same time of day, instead of letting them languish perhaps forgotten, as Overdue tasks. You can run this script from a schedule that repeats before work, or at 8:00 am or so (but after midnight in any case). It might set off quite a few reminders when it finishes!

set today to (current date)

set time of today to 0

set yesterday to (today - (1 * days))

tell application "Microsoft Entourage"

     set procrastinators to every task whose due date = yesterday ¬

          and completed is false

     repeat with procrastinator in procrastinators

          tell procrastinator



< 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