Thursday, June 07, 2007

Outlook 2007 LinkToWorkItem Macro (Convert a Work Item number into a link to the actual work item)

BUGBUG: poor title - Outlook macro for work item and changeset hyperlinks -- updated for 2007

"When I upgraded to OL2007, Buck's great little macros stopped working.  Today, I finally got the guts to ask the Outlook guys what they broke improved.  The answer was simple enough.  I'll let the code do the talking:

Sub LinkToWorkItem()
Set oDoc = ActiveInspector.WordEditor
Set oWord = oDoc.Application
Set oSelection = oWord.Selection

'' Convert the current selection to a work item hyperlink'
oDoc.Hyperlinks.Add Anchor:=oSelection.Range, Address:= _
"http://tfserver:8080/WorkItemTracking/Workitem.aspx?artifactMoniker=" _
& oSelection.Text, _
SubAddress:="", ScreenTip:="", TextToDisplay:=oSelection.Text

End Sub
..."

I email my users Work Item numbers all the time. For their future reference, so they know something has been logged, can track when one of their WI's has been released, etc.


This macro will come in handy, making it easier for me to provide them even better service and communication (links are good ;)


Update #1 6/7/2007 @ 8:10AM PDT:


OMG, I just had a major ID 10 T error (ID 10 T? Put it together... ID10T, aka Idiot  ;) Also known as a Brain Cramp or Brain Fart...


I immediately wanted to give the above snip a try. So I added the macro, found an email I just sent with a WI number in it, selected the number, executed the macro and BAM, no joy. Out of Memory error.


So I spent the next 15 minutes trying to figure out what was going on. Everything looked right, it all should have worked, I'm using Word as the email editor, the code was right, the range and selection was good, etc, etc, etc.


Then it hit me.


The email I selected the WI in was an email I previously sent. It wasn't one I WAS sending. It was in read only mode! DOGH! LOL


As soon as I opened that email for editing (by "Forward"ing it, in this case) the original macro worked just fine.


sigh... It's always the little things... :p

No comments: