{"id":10293,"date":"2005-09-20T12:15:46","date_gmt":"2005-09-20T16:15:46","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/buckh\/?p=10293"},"modified":"2019-05-06T12:16:33","modified_gmt":"2019-05-06T16:16:33","slug":"outlook-macro-to-create-work-item-and-changeset-hyperlinks","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/buckh\/outlook-macro-to-create-work-item-and-changeset-hyperlinks\/","title":{"rendered":"Outlook macro to create work item and changeset hyperlinks"},"content":{"rendered":"<p><P>[NOTE: If this post looks truncated, scroll down or make the browser window wider.&nbsp; The style sheet causes this.]<\/P>\n<P>Ed Hintz, a dev lead on the TFS Version Control team, sends a lot of email with TFS work item numbers.&nbsp; Work items&nbsp;can be viewed (not edited)&nbsp;in a web browser using an URL constructed from the server name and the work item&nbsp;number.&nbsp; Our dogfood system is a single server, so the server is always the same.&nbsp; So, Ed wrote a macro for Outlook that will convert the current selection to a hyperlink to the work item.<\/P>\n<P>Here&#8217;s the code for the macro, which he bound to Alt+L.&nbsp; The hyperlinks generated will work for beta 3, but you would need to tweak the hyperlink for earlier releases.<\/P>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\">\n<P><PRE>Sub LinkToWorkItem()<BR>&#8216;<BR>&#8216; Convert the current selection to a work item hyperlink<BR>&#8216;<BR>&nbsp;&nbsp;&nbsp; ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;http:\/\/TFserver:8080\/WorkItemTracking\/Workitem.aspx?artifactMoniker=&#8221; _<BR>        &amp; Selection.Text, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SubAddress:=&#8221;&#8221;, ScreenTip:=&#8221;&#8221;, TextToDisplay:=Selection.Text<BR>End Sub<BR><\/PRE><\/BLOCKQUOTE>\n<P>To do the same thing for changesets, use the following.<\/P>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\">\n<P><PRE>Sub LinkToChangeset()<BR>&#8216;<BR>&#8216; Convert the current selection to a changeset hyperlink<BR>&#8216;<BR>&nbsp;&nbsp;&nbsp; ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;http:\/\/TFserver:8080\/VersionControl\/VersionControl\/Changeset.aspx?artifactMoniker=&#8221; _<BR>        &amp; Selection.Text &amp; &#8220;&amp;webView=true&#8221; _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , SubAddress:=&#8221;&#8221;, ScreenTip:=&#8221;&#8221;, TextToDisplay:=Selection.Text<BR>End Sub<\/PRE>\n<P><\/P><\/BLOCKQUOTE>\n<P>If you have never created a macro in Outlook, create a new&nbsp;mail message, click in the body (otherwise, the Macros menu is disabled),&nbsp;go to Tools -&gt; Macro -&gt; Macros, enter the name &#8220;LinkToWorkItem&#8221; in the dialog&#8217;s text box, and click Create.&nbsp; In the Visual Basic Editor that opens up, paste the body of the LinkToWorkItem macro into the subroutine, save, and close the VB Editor.&nbsp; To associate it with Alt+L, go to Tools -&gt; Customize, click the Keyboard button, scroll down to Macros in the Categories list box, click in the &#8220;Press new shortcut key&#8221; text box, and press Alt+L.&nbsp; Now click Assign, Close, and Close.&nbsp; In the new mail message you have up, type a number, select it, and hit Alt+L to test it.<\/P>\n<P>Now when you want to turn a plain number into a work item or changeset link, highlight the number and run the macro via the shortcut you&#8217;ve assigned.<\/P>\n<P>[Update 10\/03\/05]&nbsp; Updated code comment.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[NOTE: If this post looks truncated, scroll down or make the browser window wider.&nbsp; The style sheet causes this.] Ed Hintz, a dev lead on the TFS Version Control team, sends a lot of email with TFS work item numbers.&nbsp; Work items&nbsp;can be viewed (not edited)&nbsp;in a web browser using an URL constructed from the [&hellip;]<\/p>\n","protected":false},"author":94,"featured_media":10268,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"acf":[],"blog_post_summary":"<p>[NOTE: If this post looks truncated, scroll down or make the browser window wider.&nbsp; The style sheet causes this.] Ed Hintz, a dev lead on the TFS Version Control team, sends a lot of email with TFS work item numbers.&nbsp; Work items&nbsp;can be viewed (not edited)&nbsp;in a web browser using an URL constructed from the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/10293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/users\/94"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/comments?post=10293"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/10293\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media\/10268"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media?parent=10293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/categories?post=10293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/tags?post=10293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}