Thanks for this posting, very useful.
I have used the above code, but had to make one minor (but important) change. I happened to be using text containing backslashes, which threw the RTF out. This was overcome by modifying the main InsertLink function to escape RTF special characters first:
Private Function EscapeRTF(ByVal sText As String) As String
sText = sText.Replace("\", "\\")
sText = sText.Replace("{", "\{")
sText = sText.Replace("}", "\}")
Return sText
End Function
Public Sub InsertLink(ByVal text As String, ByVal hyperlink As String, ByVal position As Integer)
If position < 0 OrElse position > Me.Text.Length Then
Throw New ArgumentOutOfRangeException("position")
End If
hyperlink = EscapeRTF(hyperlink)
text = EscapeRTF(text)
Me.SelectionStart = position
Me.SelectedRtf = ("{\rtf1\ansi " & text & "\v #") + hyperlink & "\v0}"
Me.[Select](position, text.Length + hyperlink.Length + 1)
Me.SetSelectionLink(True)
Me.[Select](position + text.Length + hyperlink.Length + 1, 0)
End Sub