Thank you very much!!
It really saved me a lot of time!
I revised the code a little bit as below:
Quote:
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 "." Or .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
|