I have trouble finding answer to how to work this perfectly working macro with selection.range.
Code:
Sub AddGPHLink9()
Dim oRng As Range
Dim strLink As String
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(findText:="([A-Z]{2}) ([0-9]{4,}) ([A-Z0-9]{1,2})", MatchWildcards:=True)
strLink = oRng.Text
strLink = Replace(strLink, Chr(32), "")
strLink = "website" & strLink & ".com"
ActiveDocument.Hyperlinks.Add Anchor:=oRng, _
Address:=strLink, _
TextToDisplay:=oRng.Text
oRng.End = oRng.Fields(1).Result.End
oRng.Collapse 0
Loop
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
I want to replace ActiveDocument.Range with selection.range
Tried Replace ActiveDocument.Range with selection.range and oRng.End = oRng.End + 1 But don't have proper knowledge.