2

I would like to replace the text below with only http://www.someurl.com. I have Word mac 2011. To clarify, I do not actually want to return from the field code to the actual hyperlink (blue), I only want the address as text in the document.

{ HYPERLINK "http://www.someurl.com" }

Jackson Henley
  • 1,531
  • 2
  • 15
  • 27

1 Answers1

0

Something like this (but notice it won't deal with nested fields), and unless you change Word preferences, Word will re-insert the links when you start editing the results:

Sub replaceHLs()
Dim hl As Word.Hyperlink
Dim i As Integer
Dim r As Word.Range
Dim strLinkText As String
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1
  With ActiveDocument.Hyperlinks(i)
    Set r = .Range
    strLinkText = .Address
    ' optional, should be OK for HTML links
    If .SubAddress <> "" Then
      strLinkText = strLinkText & "#" & .SubAddress
    End If
    r.Text = strLinkText
    r.Font.Color = wdColorBlue
    r.Font.Underline = wdUnderlineSingle
    Set r = Nothing
  End With
Next
End Sub