Title: ScriptLIb: get text selection or message content
Here's another common routine for scripts that operate on message text, that gets selected text or, if none is selected, the entire message content. It assumes a message window is front and it is referenced in the variable "theMsg".

-- set theText to the selection, or if none, to the entire message
set
theText to ""
try
   set theText to the selection as text
   set partial to true
end try
if
theText = "" then
   set theText to the content of theMsg
   set partial to false
end if

-- do things to theText, then replace the original with the modified copy

 if partial then
     set the selection to theText
 else
    set the content of theMsg to theText
 end if

--
Microsoft MVP for Entourage/OE/Word (MVPs are volunteers)
Allen Watson <[EMAIL PROTECTED]> Entourage FAQ site: <http://www.entourage.mvps.org/>
AppleScripts for Outlook Express and Entourage:
 <http:[EMAIL PROTECTED]/Scripts/>
Entourage Help Pages: <http://www.entourage.mvps.org/>

Reply via email to