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
Sub LinkToKB()
Set oDoc = ActiveInspector.WordEditor
Set oWord = oDoc.Application
Set oSelection = oWord.Selection
'' Convert the current selection to a KB article hyperlink'
oDoc.Hyperlinks.Add Anchor:=oSelection.Range, Address:= _
"http://support.microsoft.com/kb/" _
& oSelection.Text, _
SubAddress:="", ScreenTip:="", TextToDisplay:=oSelection.Text
End Sub
Sub LinkToChangeset()
Set oDoc = ActiveInspector.WordEditor
Set oWord = oDoc.Application
Set oSelection = oWord.Selection
'' Convert the current selection to a changeset hyperlink'
oDoc.Hyperlinks.Add Anchor:=oSelection.Range, Address:= _
"http://tfserver:8080/VersionControl/VersionControl/Changeset.aspx?artifactMoniker=" _
& oSelection.Text, _
SubAddress:="", ScreenTip:="", TextToDisplay:=oSelection.Text
End Sub
LinkToKB() technically doesn't have anything to do with TFS, but I went ahead and added it while I was playing with Outlook macros.
In the next post, you'll see why...