I tried to use your code , but it seemed unable to trim the unwanted punctuations.
For example,
Code:
Roa, Felipe Suescun de, Comments on the ICSID Award Saipem v. Bangladesh: Would its rationale be applicable in future cases?, INT'L INST. FOR CONFLICT PREVENTION & RESOL. (May 5, 2011), http://www.cpradr.org/news-publications/articles/2011-05-05-comments-on-the-icsid-award-saipem-v-bangladesh-would-its-rationale-be-applicable-in-future-cases-2011-writing-contest-winner.
This url-text cannot be recognized correctly, still includes the last period.
Code:
Sub ConvertURLTextsToHyperlinksInDoc()
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 ]{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
End Sub