1
votes

I prepare a MS Word file with a large amount of news articles, each followed by a full, long clickable hyperlink (e.g. http://www.newssite.com/this-is-the-name-of-the-article.html).

I need to replace all the hyperlinks in the file with a single word: "Link", while keeping their url adresses and click functionality. I can use MS Word "change hyperlink" dialogue to do that, but doing it by hand takes incredible amount of time.

The hyperlinks, however, are not always formatted as 'hyperlink' style. Is there any condition for MS Word Macro replacement that will lookup hyperlinks by their functionality, not by their style or text?

Despite this task seems to be quite common, I could not find anything like it in the web.

1

1 Answers

0
votes

Since you have the hyperlinks already created. It should just require looping through the documents hyperlinks collection and changing the 'TextToDisplay' property. This should get you started:

Public Sub ChangeHyperlinksText()

    Dim hlink As Hyperlink

    For Each hlink In ThisDocument.Hyperlinks
        hlink.TextToDisplay = "Link"
    Next hlink
End Sub