Replace LINK text

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Replace LINK text

Post by ErikJan »

How do I replace the displayed text in links (in a Word 2003) document? There are all different links with text like "Click here", I want that to be changed into e.g. "Link"

User avatar
HansV
Administrator
Posts: 78604
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Replace LINK text

Post by HansV »

Can't you simply enter Click Here in the Find what box and Link in the Replace with box in the Replace dialog? Or is that too naive?
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Replace LINK text

Post by ErikJan »

That's what I did but that didn't work...

User avatar
HansV
Administrator
Posts: 78604
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Replace LINK text

Post by HansV »

In what way did it fail? I tried it just now and it worked flawlessly (I have to admit that the text "Click here" didn't occur elsewhere in the document).
Best wishes,
Hans

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Replace LINK text

Post by macropod »

Hi ErikJan,

Try something like:

Code: Select all

Sub EditHyperlinkDisplayText()
Dim oHLNK As Hyperlink
For Each oHLNK In ActiveDocument.Hyperlinks
  On Error Resume Next
  oHLNK.Range.Select
  oHLNK.TextToDisplay = InputBox("Change Display Text?", "Hyperlink Display Text Editor", oHLNK.TextToDisplay)
Next
End Sub
Paul Edstein
[Fmr MS MVP - Word]

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Replace LINK text

Post by ErikJan »

HansV wrote:In what way did it fail? I tried it just now and it worked flawlessly (I have to admit that the text "Click here" didn't occur elsewhere in the document).
Nothing found to replace... (and yes, I also copied the text-to-replace and pasted in into the 'find' box to make sure there were no typo's) :grin:

User avatar
HansV
Administrator
Posts: 78604
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Replace LINK text

Post by HansV »

I don't know why it doesn't work for you. See if macropod's macro does what you want.
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Replace LINK text

Post by ErikJan »

I used the code snippet, modified it a little to find only the text I was looking for and immediately replace that with the new text. That did work out fine. Thanks for the help!