Create special Paste macro to wrap HTML tags around text

I’m doing some work that requires me to copy a large number of HTML tags and paste them into an IE8 window. The tags are of the format:

<A href="[A bunch of javascript]">Text to be linked</A>

What I’d like to do is create a special Paste macro (the javascript is different in each case, so it’d have to read the exact tag out of the clipboard) that will replace the text to be linked with the text that I’ve selected to paste over, and then bind this macro to a key combination — say, CTRL+Shift+V.

So, for example, if I were to copy the sample HTML, highlight the word “work” in the first sentence of this post, and press CTRL+Shift+V, it would produce this:

I’m doing some <A href="[A bunch of javascript]">work</A> that requires me to copy a large number of HTML tags and paste them into an IE8 window.

Does anyone know of a utility that will allow me to do this? I know of a few macro utilities out there, but I’m hoping someone can recommend one that’s (relatively) quick to do this sort of thing. Thanks in advance for any advice.

Does [A bunch of javascript] depend on what you highlight?

For example, would it be [A bunch of javascript about work]>work</a>
and
[A bunch of javascript about chickens]>chickens</a>

Or the same bunch for any highlighted word?

It seems like AutoHotkey might be able to do this.

Edit: It can, and you don’t even need to fiddle with hotkeys or the clipboard:
http://www.autohotkey.com/docs/Hotstrings.htm

Like MS Word’s autocomplete, it will automatically change “work” into <A href=“[A bunch of javascript]”>work</A> in any program.

To answer your earlier question, yes, the javascript changes based on the term to be linked, but the term varies ever-so-slightly, for example:

<A bunch of javascript about chickens>chickens</a>
<A bunch of javascript about chickens>chicks</a>
<A bunch of javascript about chickens>Chicken</a>
<A bunch of javascript about work>work</a>
<A bunch of javascript about work>Working</a>

Right now I’m just pasting the entire tag with the “chickens” or “work” text and making corrections myself, but that’s getting old fast, hence the thread. Your suggestion looks like it might do the trick if I create short strings for each version, which might be workable. I’ll play around with it. Thanks!