Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Checking for Valid Hyperlinks.

Checking for Valid Hyperlinks

Written by Allen Wyatt (last updated December 6, 2021)
This tip applies to Word 97, 2000, 2002, and 2003


5

Raghu has a document that has a good number of hyperlinks in it to various Websites. He wants to step through each of the hyperlinks and have them checked, programmatically, to see if they are valid links that don't generate errors.

There is no way to do this automatically in Word, as such functionality is not built into the program. If you only have a few links in the document, you might try saving it as an HTML file. You could then load the file in Internet Explorer and click each link to see if it is valid.

If you are searching for a more automatic method of checking, you would need to create a macro that would step through the links in a document and check them out. The VBA code could end up being rather complex.

Perhaps a better solution, rather than writing your own code, is to use a third-party add-in that can do the checking for you. In searching around, the following add-in was discovered:

https://www.ablebits.com/word-links-checker/

We haven't tried this add-in, but it appears to do everything that Raghu wanted. Perhaps the best news: the add-in is free.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (517) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Checking for Valid Hyperlinks.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Missing PivotTable Data

Wonder what happened to the data behind a PivotTable? It could be in a number of places, and tracking it down could be a ...

Discover More

Ensuring Conditional Formatting and Data Validation is Copied

If you use an Excel worksheet for entering data (a quite common task, actually), then you need to be concerned with how ...

Discover More

Aligning Numbered Lists on the Period

When you convert a paragraph to a numbered list, Word adds a number at the start of the paragraph, as you would expect. ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Setting Web Fonts

If you intend to generate a Web page from your document, you need to be concerned with the fonts that Word will use. ...

Discover More

Making Live URLs Into Normal Text

Convert those URLs into regular text! It's easy to do when you follow the steps in this tip.

Discover More

Getting Rid of Many Hyperlinks

Need to get rid of hyperlinks that result when you paste information from the Internet into your document? Here's the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 + 5?

2017-11-17 14:13:49

Oliver

Allen, maybe to extend a bit. In case if you want to identify broken links in Word documents but also to fix them we have ReplaceMagic.Word (it is not free tool :-( ) which can do that.

Direct link is:

https://www.replacemagic.com/RMWordEdition.aspx

ReplaceMagic does not require Word on the computer where it is installed and it can process multiple documents in parallel. Another advantage is that you can instruct ReplaceMagic to fix links (you will need to know what was wrong part of the link and what should be new, for example, before you had //server1/something and now you need //server2/something. By setting as search string server1 and as replacement string server2 ReplaceMagic will make changes.
Of course, you have to specify a location where the document(s) are :).

ReplaceMagic will fit scenarios where you need mass replacements and you'll not need to open a single document.
Of course, for smaller changes would be better to create macro or similar and last comment abblebits is not free (cost very small amount of $ ).


2017-01-18 04:20:26

Ken Endacott

Thomas, thank you for your praise. Most of the documents that I see have links to web pages but It seems that you are looking at links to documents. The macro lumps documents with web pages and while it should open documents for eyeballing it would be possible to add to the macro to handle documents more effectively.

Something to add to my to-do list.


2017-01-16 09:28:36

Thomas Redd

As pointed out by Mick, I found the same thing about the product. It is free for two weeks and it works well. I was stuck and lock out of it when the link went to a passworded document. The first password was required and worked, but when I got to the next reference that was passworded, it hung and would not go on. It is not too costly-about $10.00, but I don't want to pay that for a product that will not work for me. I am excited to try Ken Endacott's macro. His work has been exceptional in the other tips. Thanks so much for all you do! These tips are the greatest!


2017-01-15 07:04:26

Ken Endacott

Checking hyperlinks can involve more than checking for a valid link. It is usually necessary to check that the link is to a relevant page and this can only be done by eyeballing the page.

The following macro will step through hyperlinks and test them for validity. Internal hyperlinks are checked to determine if they refer to a valid bookmark. External hyperlinks are checked to determine if the link is valid. If the link is valid then the page is opened and the user is asked if the page is relevant.

Invalid or incorrect hyperlinks are highlighted in yellow.

Sub CheckHyperlinks()
Dim hp As Hyperlink
Dim bk As Bookmark
Dim bTest As Boolean
Dim st As String
Dim k As Long
For Each hp In ActiveDocument.Hyperlinks
hp.Range.Select
st = ""
On Error Resume Next
st = hp.Address
If st = "" Then
' hyperlink is to an internal bookmark
st = hp.SubAddress
bTest = False
ActiveDocument.Bookmarks.ShowHidden = True
For Each bk In ActiveDocument.Bookmarks
If st = bk.Name Then bTest = True
Next bk
If bTest = False Then
If MsgBox("Error. Internal hyperlink to non existent bookmark.", vbOKCancel) = vbCancel Then Exit Sub
Selection.Range.HighlightColorIndex = wdYellow
End If
Else
bTest = True
On Error GoTo hpERR
ActiveDocument.FollowHyperlink Address:=st
On Error GoTo 0
If bTest = False Then
k = MsgBox("Invalid URL in hyperlink", vbOKCancel)
Else
k = MsgBox("Did hyperlink find a relevant web page", vbYesNoCancel)
End If
If k = vbCancel Then Exit Sub
If k = vbNo Or k = vbOK Then
Selection.Range.HighlightColorIndex = wdYellow
End If
End If
Next hp
Exit Sub
hpERR:
bTest = False
Resume Next
End Sub


2017-01-14 05:55:29

Mick

Allen, sir,

First of all, I thank you for your weekly tips on using Microsoft Word. The information you offer is invaluable.

You MAY, however, wish to edit this post as the link that you provide for the Word Link Checker shows that it is NOT free. Only the Trial is free, though I'm not sure how long the trial lasts for.

Mick


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.