title: vbscript ms word find and replace text with hyperlink
body: <p>I have some vbscript which uses find and replace to populate a signature template.  it works well but I would like some text to appear as a hyperlink.  I have tried various things but don't really know what I'm doing so would be grateful for any pointers.</p>
  
  <pre><code>Sub SearchAndRep(searchTerm, replaceTerm, WordApp)
  WordApp.Selection.GoTo 1
  Set objSelection = objWord.Selection
  
  objSelection.Find.Text = searchTerm
  objSelection.Find.Replacement.Text = replaceTerm &amp; ""
  objSelection.Find.Forward = TRUE
  objSelection.Find.MatchWholeWord = TRUE
  
  If objSelection.Find.Execute Then
  
    Select Case searchTerm
      Case "%ScannedSignature%"
  
        WordApp.Selection.TypeBackspace()
  
    PictureFile="\\bb01.com\bwbdfs01\users\Signatures\scanned\" &amp; replaceTerm
    Set fs = CreateObject("Scripting.FileSystemObject")
  
    If fs.FileExists(PictureFile) Then
      Set objShape = objSelection.InlineShapes.AddPicture(PictureFile)
    Else
      WordApp.Selection.MoveEnd
      WordApp.Selection.TypeBackspace()
      wscript.echo("Could not find scanned logo")
      wscript.echo(PictureFile)
    End If
    Set fs = Nothing
  
  Case "%LinkedIn%",
    'This is where my code will go to insert a hyperlink
  
  Case "%TelephoneLine3%", "%TelephoneLine4%"
  
    If replaceTerm &amp; "" &lt;&gt; "" Then
      objSelection.Find.Execute,,,,,,,,,,2
    Else
      WordApp.Selection.TypeBackspace()
      WordApp.Selection.TypeBackspace()
      WordApp.Selection.TypeBackspace()
    End If
  
  Case Else
  
    If replaceTerm &amp; "" &lt;&gt; "" Then
      objSelection.Find.Execute,,,,,,,,,,2
    Else
      WordApp.Selection.TypeBackspace()
      WordApp.Selection.TypeBackspace()
    End If
  
  End Select
  
  Else
    'Do nothing
   End If
  End Sub
  </code></pre>