Title: [Script]] Make Note from Selected Text
I often use notes in Entourage as an "in-application" clippings function, saving addresses and phone numbers I might use once and don't want to add to the address book, text snippets, etc. Microsoft has included a handy script to make a note from a message, fine for when you want to save an entire message, but for selected text from a message. As usual Paul Berkowitz has done the major work for the script I'm posting, his script was for making a new event from selected text, I modified it for making a new note and to throw up a dialog allowing you to name the new note. If you clear the default text for the name, or if you simply hit OK to the prompt, it will use the message Subject from where the text is selected for the note name. I did this because I found it very unlikely that I would ever name a note "Type New Note Name Here"  if I accidentally hit OK without changing the default text. Uses Standard Additions for the dialog display and works fine for me under Mac OS 9.04.

As always, I'm grateful to Paul for the framework.

-- Script from a message sent by Paul Berkowitz
-- on Thursday, October 12, 2000 8:42:53 PM
(* Modified ever so slightly by Jim Baskins on October 18, 2000 from Paul's Make Event Selected Text Script. *)

-------------------------------Make Note Selected Text--------------------


global selectedMessages

tell application "Microsoft Entourage"
    activate
    -- get the currently selected text
   set selectedMessages to current messages
    set theSelection to the selection
    if class of theSelection = string then
       set selectedText to theSelection -- could be "" if focus is in message text
       set frontMsg to displayed message of window 1
        my MakeNote(frontMsg, selectedText)
    else
       set selectedText to "" -- to define it
       repeat with theMessage in selectedMessages
            my MakeNote(theMessage, selectedText)
        end repeat
   end if
   
    -- if there is no text selected, select the current message or messages
end tell

to MakeNote(theMessage, selectedText)
    tell application "Microsoft Entourage"
        
        -- get the information from the message, and store it in variables
       
        set theName to text returned of (display dialog "Enter a Name for this Note" default answer "Type New Note Name Here")
        if theName = "" then
       else if theName = "Type New Note Name Here" then
           set theName to subject of theMessage
        end if
       set theCategory to category of theMessage
        
        if selectedText = "" then
           set theContent to content of theMessage
        else
           set theContent to selectedText
        end if
       -- create a new note with the information from the message
       set newNote to make new note with properties {name:theName, category:theCategory, content:theContent}
        
        -- create a link between the message and the new note
       link theMessage to newNote
        
        -- if there was only one message selected, then open that new note
       if (count of selectedMessages) = 1 then open newNote
    end tell
   
end MakeNote


----------------------end script-----------

Regards,
Jim Baskins

Reply via email to