View Single Post
 
Old 07-28-2018, 11:33 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub ConvertURLTextsToHyperlinksInDoc()
Application.ScreenUpdating = False
Dim wdRng As Range
For Each wdRng In ActiveDocument.StoryRanges
  With wdRng
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "htt[ps]{1,2}://[!^13^t^l ^s]{1,}"
      .Replacement.Text = ""
      .Forward = True
      .Format = False
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found
      If .Characters.Last Like "[:;.,(?)!})]" Then .End = .End - 1
      .Hyperlinks.Add .Duplicate, .Text, , , .Text
      .Start = .Hyperlinks(1).Range.End
      .Find.Execute
    Loop
  End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote