Copy highlighted text and replace it using AppleScript I'm struggling to get a basic AppleScript script running correctly. Here is what I want to do:

User highlights text, shortcut key is pressed and then AppleScript will copy the selected text and type something before it and something after it. 

Here is the script I have, it doesn't seem to execute correctly, anyone have an idea why?

on run
    tell application "System Events"
        keystroke "c" using command down
        keystroke "&lt;answer&gt;"
        keystroke "v" using command down
        keystroke "&lt;/answer&gt;"
    end tell
end run
This might do the trick:

on run
    tell application "System Events"
        keystroke "c" using command down
    end tell

    tell application "Finder"
        set x to the clipboard
        set x to "Today " &amp; x &amp; " a sunny day"
        set the clipboard to x
    end tell

    tell application "System Events"
        keystroke "v" using command down
    end tell
end run


Though it might be better to write the script without using the clipboard (i.e., without copying and pasting), but that requires involvement of the application(s) you are working with, and you did not tell us which ones they are.