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 138
So it looks like a bug, but I believe it may be a result of the brand new (in Entourage 2004 11.2) ability to move items to, and on, servers (Exchange and IMAP), and so is forgivable. It used to be impossible to move messages, contacts, or events on or to servers: this is because both move and duplicate, in the Standard Suite and as dictated by Apple, must return a result: namely, the moved or duplicated item. But IMAP and Exchange servers cannot be relied on to return results of new items without a timeout, so this ability was simply lacking: not implemented.
Entourage 11.2 gets around this problem by guaranteeing the same ID for a "moved" item (which really and truly is a new item in the new location, with the original item then deleted, as are all "moves" on computers in every context), so Entourage can return the ID result immediately "on faith" without having to wait for the server to return it. That means that behind the scenes, IDs are now copied, or replaced. That can never be with a duplicated item: both items would then have the same ID, which is impossible. So move is possible, but not duplicate.
So the way to do a "copy" is to create a new event based on the properties of the old one. You could certainly get all the properties of the original event and then make a new event at the calendar you want with properties etc., and that is the traditional way to do it.
But if you wanted to do this, say, for all your 3000 events from one calendar to another, it would take a very long time, since a separate AppleEvent is sent for both getting and setting every single property, even when in a with properties block. It would be even slower for contacts, which have about 65 properties and elements to check (you could avoid writing blank default properties, I guess).
A much faster way is to make use of the iCal data property (the equivalent for contacts is the vcard data property, which we have seen before in Attach a vCard script), which will get and make most of the properties in one fell swoop. It is much, much faster.
The only properties you'd have to get and make separately, if they are important to you, would be the category, project list, and links properties which are proprietary to Entourage and not included in iCal data. (There is also one feature, Travel Time, which is not caught either by iCal data nor by any AppleScript property.) With contacts, there is the added bonus that vcard data gets the picture, too, for which there is still no AppleScript property.
The only snag is that you cannot make a new event from iCal data at an Exchange calendar, only at the local calendar. But that's not a big snag: you just make it at the local calendar and then move it. Here's the script, for copying one event (add your own code to check for the class of the selected item). You can omit links and project list if you don't use them.
tell application "Microsoft Entourage"
set theEvent to item 1 of (get selection)
set {iCalData, theCategories, theProjects, theLinks} ¬
to theEvent's {iCal data, category, project list, links}
set dup to make new event at calendar id 13 with properties ¬
{iCal data:iCalData, category:theCategories, project list:¬
theProjects}
repeat with i from 1 to (count theLinks)
set theLink to item i of theLinks
link theLink to dup
end repeat
move dup to primary calendar of Exchange account 1
-- or to any calendar
end tell
No Notes?
If you've read this far, you won't have any trouble making or opening notes, which have only four settable properties: name, content, category and project list. It's a shame that Entourage, an application that involves a great deal of text in almost all its objects, does not make formatted text, as available in HTML draft windows and in notes, scriptable, So there's not much more to say.
Likewise, projects are hardly scriptable, custom views even less so (just their names), and rules not at all. Maybe in a later version… Still, it is quite amazing how much of Entourage is scriptable, sometimes past what the UI can do (such as making incoming messages). It is a very powerful AppleScript implementation, all in all.
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine