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 128
Finally, the script links the task to the contact and opens the task, i.e., its window – which is precisely why we set a variable theTask when making it, to be able to follow up with the two final commands to link and open it. You can then adjust the due date and reminder time if you wish. If you think you might use this script in future, save it to Entourage Script Menu Items folder and add a keyboard shortcut such as \cmC (control-command-C) to the end of its name.
Copy to a Custom Field (Contacts)
If you export Entourage contacts to a text file via File/Export/Local contacts, you will have discovered that it does not export the Category information for the contacts. There are times, for example if you then import the text file into Excel, when you really need to have the Category information. One way to get it is to use a script to enter the category names in one of Entourage's custom fields. There are 8 of those, and you usually won‘t need all of them. Let's say you want to enter the Category information in Custom 8 field.
You probably should rename that to "Categories"; of course that's easy to do in the address book (open any contact click on the Custom 8 label and choose Edit Label) but it's also possible to do that by script, which we will do. Note that contacts (and other Entourage objects) can have more than one category: that's why category property of contact (and of event, task, note, group, etc.) is a list of categories.
For our script we'll need to use a separator when converting the list of category names to text: here we'll use a comma but you could use any other separator, e.g., a semicolon, or slash, if you prefer. The way to do this is to set AppleScript's text item delimiters to the chosen separator character (within list braces), and then coerce the list to text.
You should then reset the delimiters to whatever they were, namely the default "" in most cases, afterwards, because the delimiters are retained for the entire session (i.e. until Quit) of whatever application is running the script (Script Editor, Entourage if run from its menu, System Events if run from the system menu, etc.) and might mess up other scripts if they are not rigorous (as they should be) about setting delimiters before coercing lists to text.
Here is the script:
tell application "Microsoft Entourage"
set custom field eight name of address book 1 to "Categories"
set categoryContacts to every contact ¬
where its category {}
repeat with i from 1 to (count categoryContacts)
set theContact to item i of my categoryContacts
set catNames to {}
set theCats to category of theContact
repeat with j from 1 to count theCats
set theCategory to item j of theCats
set end of catNames to name of theCategory
end repeat
set AppleScript's text item delimiters to {", "}
set catNames to catNames as Unicode text
set AppleScript's text item delimiters to {""}
set custom field eight of theContact to catNames
end repeat
beep
display dialog "All done!" buttons {"OK"} ¬
default button "OK" with icon 1
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine