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.
|
April, 2007
Page 137
set due date to today
if has reminder then
set reminderTime to remind date and time
set remind date and time to (reminderTime + (1 * days))
end if
end tell
end repeat
end tell
This one is pretty straightforward. One thing to be aware of here is that Entourage considers that tasks without reminders nevertheless still have a remind date and time of date "Friday, January 1, 1904 12:00:00 AM". Before Entourage 2004, there was no has reminder boolean property (a very useful property: in the script above we are checking for tasks where has reminder is true) so scripts had to check for that 1/1/1904 date instead, and you may still see many scripts that do so.
(You probably know that the Mac, or some Mac applications anyway, still treat Jan. 1 1904 as "the beginning of time" for some purposes when they are restricting themselves to functions that can't handle more than 2^31 seconds (which brings you up to Feb. 5, 2035 "the end of time"). Excel has a similar limit, although it has an option to treat Jan. 1, 2000 instead as the beginning for compatibility with the Windows version.
Move Calendar Events to Exchange (or to "My Computer")
For anyone on an Exchange Server, Entourage 2004 11.2 brought greatly increased functionality, including multiple calendars and address books. (There are some who think that the next version of Entourage might bring these to everyone, without Exchange. Time will tell…) That gives you the option of keeping private items on your local calendar "On My Computer" and work items on the Exchange calendar, for example. But there is no way to superimpose them to see your whole schedule at once.
So some people would appreciate a quick way of getting events from one calendar to the other, and the same for contacts in different address books too. To actually keep them in sync would require a very complex script, far to big to demonstrate here. But if you are content to merge all your events by moving all events from one calendar to the other, you could actually keep this going by running the script periodically.
Here's a version that moves all events from the local calendar "On My Computer" to the primary personal Calendar (usually just called, in fact "Calendar") on your Exchange account:
tell application "Microsoft Entourage"
move (every event of calendar id 13) to primary calendar ¬
of Exchange account 1
end tell
That's it. Or you could do it the other way around. Note that the local calendar has a fixed built-in ID: it is always id 13. (The local address book is address book id 14.) Underneath, they are now actually folders – since v11.2, calendar and address book classes are subclasses of folder. You can also refer to them as calendar 1 and address book 1. Presumably that won't change either. But don't try any of this pre-11.2 aside from address book 1, which always worked.
calendar was not even a class at all before v11.2. There's nothing you could do with it pre-v11.2. events and contacts were just elements of the application, not of calendar and address book as they are now. One extremely useful thing to know is that you can still treat events and contacts as elements of the application – so older scripts do not break – but in that case the only ones found and recognized are the events and contacts belonging to the calendar and address book associated with your default email account.
If you don't have an Exchange account, then you don't need to concern yourself with this at all, since you have only local calendar, events, address book, and contacts, and all will be found. If you do have an Exchange account, then if the Exchange account is your default mail account, only your Exchange events and contacts of your primary Exchange calendar and address book will be found when you (or an older script) does not specify which one.
If you set a POP or IMAP account as your default mail account, then only your local events and contacts "On My Computer" will be found. So you can switch from one to the other by switching the Default account in Tools/Accounts/Mail. But since you now are writing and editing our own scripts, you can always specify precisely which calendar or address book you mean, including all subsidiary calendars and calendar subfolders, by name or ID. (If by name you need to always show the whole hierarchy:
calendar "Extra" of calendar "Calendar" of Exchange account 1
If you have more than one Exchange account, you'll need to refer to each one by name (or get its ID): doing so by index number is not reliable if you add and remove accounts, and even its ID may change (as with all objects in Entourage) if you ever rebuild the database. On the other hand, the name can be changed at any time, so ID is usually more reliable, until you rebuild.
You may be wondering about copying, rather than moving, the events. duplicate (in the Standard Suite) does not work for events, not even without the to parameter to duplicate a local event in the same location (from where you could move the duplicate to the other calendar). The error you get when you try that ("Can't set event id 1295 to event id 1295.") indicates that it's trying to duplicate the ID as well, which of course is not possible: ID is read-only, is unique, and is generated automatically when a new object is created.
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine