Converting Hyperlinks to Footnotes

Written by Allen Wyatt (last updated February 15, 2020)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


3

Stephen has a large document (300+ pages) that includes a large number of hyperlinks in the main text. There are, as well, footnotes in the document. Each of the hyperlinks needs to be converted into a footnote, which will (of course) increase the number of footnotes in the document. The increase isn't a problem. The problem is coming up with a fast way to convert all of those hyperlinks to footnotes. Stephen wonders if this could be done using a macro.

This can, indeed, be done with a macro. In fact, the macro may be simpler than you might imagine. Here's an example:

Sub LinksToFootnotes()
    Dim hLink As Hyperlink
    Dim rTemp As Range
    Dim J As Integer

    For Each hLink In ActiveDocument.Hyperlinks
        Set rTemp = hLink.Range

        ' Create footnote
        ActiveDocument.Footnotes.Add Range:=rTemp, _
          Text:=rTemp.Text

        ' Delete possible leading space
        rTemp.Collapse
        rTemp.MoveStart Count:=-1
        If rTemp.Text = " " Then rTemp.Delete
    Next hLink

    ' Delete hyperlinks
    For J = ActiveDocument.Hyperlinks.Count To 1 Step -1
        ActiveDocument.Hyperlinks(J).Range.Delete
    Next
End Sub

This example does two passes through all the hyperlinks in the document. During the first pass it creates the footnotes and during the second pass it deletes the hyperlinks. Note, as well, that portion of the code that checks to see if there is a space before the hyperlink. This is done so that if there is, that space can be deleted to put the resulting footnote number right next to anything before that space. (In other words, if this wasn't done, it is a good bet that every footnote number would have a space before it.)

That brings up another issue with the macro that you should be aware of—all it does is to create the footnotes and delete the hyperlinks. If there is any information surrounding the original hyperlink (such as parentheses, commas, or periods), those characters will be left in the document. This means that you should do a manual pass through your document after running the macro to make sure that the possible extraneous characters are edited as you want them to be.

Finally, note that the hyperlinks placed into the footnotes are not active hyperlinks—they are text only. This isn't a big issue, though, as plain text is typically what is desired when creating documents that contain footnotes.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13739) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

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

Entering Many Items In a Drop-Down Form Field

One of the controls you can add to a Word form is a drop-down form field. This field is similar to drop-down lists used ...

Discover More

Inserting Cells in a Table

You can enlarge a table by adding cells where they are needed. Just pick where you want the cells inserted, then use the ...

Discover More

Increasing the Capacity of AutoCorrect

AutoCorrect can be a great tool to, well, "correct" information that you type. If you get a little creative, you can even ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Formatting Footnotes and Endnotes

Footnotes and endnotes can be formatted in the same way that you format regular text in your document. There is an easier ...

Discover More

Viewing Footnotes

Adding footnotes to a document is essential for some types of writing. How you view those footnotes depends on the ...

Discover More

Turning Off Printing of Document Properties

Getting to a printed document is often the entire purpose of using Word. The program, however, allows you to print out ...

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 two more than 7?

2020-02-17 07:54:45

Chuck

Perfect. It works great now. Thank you, Ken!


2020-02-16 03:35:34

Ken

Try adding the statement rTemp.select immediately before the statement that was in error. Then the particular hyperlink that caused the error will be highlighted and can be examined. For example, the hyperlink might be nested inside another field. ALT + F9 will toggle field displays between the field codes and results.

To put the hyperlinks in endnotes, change the word Footnotes to Endnotes in the statements.


2020-02-15 09:48:09

Chuck

Great tip. Thank you. I have two questions, please.

I have Office 365 Pro Plus.

First, when I try to run this I get this error:

Run-time error '4680':
That property is not supported for this object

When I debug, it takes me to the line

Set rTemp = hLink.Range

What did I do wrong?

The second question, is how would I do this for endnotes. My third question is how to get the links as just lines in the body of the document, but that may be asking too much. :-)

Thank you again.

Chuck


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu 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.