View Single Post
 
Old 07-20-2020, 08:50 AM
scientist101 scientist101 is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2020
Posts: 6
scientist101 is on a distinguished road
Default

Thanks so much. I had resorted to toggling field codes and then using find and replace. There's probably a more elegant way to do this, but I just hooked the two macros together:

Sub MakeMyLink()
Dim aRng As Range, sFound() As String, sLink As String, sText As String
Set aRng = ActiveDocument.Range
With aRng.Find
.Text = "\<\<(*)\>\>\<\<(*)\>\>"
.matchwildcards = True
.Replacement.Text = "\1|\2"
Do While .Execute
sFound = Split(aRng.Text, ">><<")
sLink = Replace(sFound(0), "<<", "")
sText = Replace(sFound(1), ">>", "")
ActiveDocument.Hyperlinks.Add Anchor:=aRng, Address:=sLink, SubAddress:="", ScreenTip:="", TextToDisplay:=sText
aRng.Collapse Direction:=wdCollapseEnd
Loop
End With
ChangeHL
End Sub

Sub ChangeHL()
Dim aHL As Hyperlink, sLink As String
For Each aHL In ActiveDocument.Hyperlinks
sLink = aHL.Address
sLink = Replace(sLink, "C:\Users\iaman\Desktop\eCTD_Office_Software\IND_S ource_Folders\YFV_IND", "..")
sLink = Replace(sLink, "", "/")
aHL.Address = sLink
Next aHL
End Sub


Cheers!
Reply With Quote