title: Create macro to make text into hyperlink concatenating the display text to standard format
body: <p>I have to create a large number of hyperlinks for ticket items where the only part of the URL that changes is the ticket ID. I am new to this and much of the VBA help is for excel. My problem exists in MS-word and its difficult to transfer the syntax. </p>
  
  <p>I expect the user to invoke the macro after entering a 6 digit Ticket ID. Ideally the macro would automatically select the last word typed by the user, and append it to the url segment which never changes.</p>
  
  <p>I attempted to record a macro that copies the last word typed then concatenates it onto the end of the standard URL. </p>
  
  <p>I can successfully do everything with keyboard shortcuts so I thought I would be set. The problem is the macro just uses the text from the recording example. It also turns my text to display to the example text. </p>
  
  <p>Turning any text into the link I used as an example in the recording. </p>
  
  <p>I can't figure out how to make VBA use the copied text for the text to display and the last 6 digits of the URL. </p>
  
  <p>Please see VBA syntax below </p>
  
  <pre><code>Sub textToHyperlink()
  '
      Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
      Selection.Copy
      ChangeFileOpenDirectory _
          "/Users/chris/Library/Containers/com.microsoft.Word/Data/Library/Preferences/AutoRecovery/"
      ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
          "https://someboringwebsite.com/WorkItem&amp;id=123456", SubAddress:="", ScreenTip:="", _
          TextToDisplay:="123456"
  
  End Sub
  </code></pre>