Title: Re: How can I add the category?
On 4/17/04 5:20 PM, "Bruce Klutchko" <[EMAIL PROTECTED]> wrote:

This is a slightly modified version of a script you sent me a few months ago to place all selected tasks into a note. I added a date to the name and the priority to the printout. I’d also like to add the category of  each task to the printout, but it seems that the category is a list and will not convert to unicode. I am able to get the number of the category, but not the name of the category.

Is there a simple way to add each task’s category to the note?

Well, first you have to get the names of the categories from that list, then coerce them to text (I use a comma-and-space to separate them if more than one:

property separator : "---------------------------------------------------------------------------------------------"

set today to short date string of (current date)

tell application "Microsoft Entourage"
    activate
   select main window -- brings it to front
   try
       set dispArea to displayed area of main window
       if dispArea is not tasks area then error number -128
    on error
       beep 2
        display dialog "You must first select some tasks in the Tasks List." buttons {"OK"} default button 1 with icon 0
        return
   end try
   try
       set selectedTasks to the selection
   on error
       beep 2
        display dialog "You must first select some tasks in the Tasks List." buttons {"OK"} default button 1 with icon 0
        return
   end try
   
    set notesText to "" as Unicode text
   
    repeat with theTask in selectedTasks
       set {theName, theDueDate, theNote, thePriority, theCategories} to theTask's {name, due date, content, priority, category}
        set categoryNames to {}
        repeat with i from 1 to (count theCategories)
            set aCategory to item i of theCategories
           set end of categoryNames to (name of aCategory)
        end repeat
       set AppleScript's text item delimiters to {", "}
        set categoryNames to categoryNames as Unicode text
       set AppleScript's text item delimiters to {""}
        if categoryNames = "" then set categoryNames to "None" -- optional    
       try -- works in Panther
           set theDueDate to short date string of theDueDate
       on error
           set theDueDate to date string of theDueDate
       end try
       set notesText to notesText & "• " & theName & "  -   " & theDueDate & "    -    Priority: " & thePriority &  " - " & "Categories: " & categoryNames & return & theNote & return & separator & return
   end repeat
   
    set tasksNote to make new note with properties {name:"Tasks Note  -  " & today, content:notesText}
    
    open tasksNote
   try
       print tasksNote
   end try
   
end tell


-----------------------------------------------------------


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

PLEASE always state which version of Entourage you are using - 2001 or X. It's often impossible to answer your questions otherwise.

Reply via email to