That's great. Thanks very much
I've enhanced to wildcard match:
Code:
Sub Macro1()
Dim oRng As Range
Dim sFind As String
Dim sAddr As String
Dim sPath As String
sFind = "\((X[0-9]{5})\)"
Set oRng = ActiveDocument.Range
With oRng.Find
.MatchWildcards = True
Do While .Execute(sFind)
'sAddr = oRng.Text
sAddr = "???"
sPath = "folder\file " & sAddr & ".txt" 'assemble the link path
Debug.Print sPath
oRng.Hyperlinks.Add oRng, sPath, , , oRng.Text
oRng.End = oRng.Hyperlinks(1).Range.End
oRng.Collapse 0
Loop
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
but cannot find how to set sAddr to the first captured expression e.g. X12345. Any idea?
Attached.