View Single Post
 
Old 10-12-2025, 12:33 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

There is no function that will automate this, but you should be able to achieve it with a macro e.g.
Code:
Sub Macro1()
Dim oRng As Range
Dim sFind As String
Dim sAddr As String
Dim sPath As String
    sFind = "(Xnnnn)" 'the text to find
    sAddr = Mid(sFind, 2, Len(sFind) - 2) 'remove the brackets from the searched text
    sPath = "folder\file " & sAddr & ".txt" 'assemble the link path
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(sFind)
            oRng.Hyperlinks.Add oRng, sPath, , , sFind
            oRng.End = oRng.Hyperlinks(1).Range.End
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
The code assumes that sPath is a genuine path accessible from the document.
Note that I have not tested it with Word 2003, but I am pretty sure all the code examples worked in that version.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote