Pulling All Hyperlinks

by Allen Wyatt
(last updated July 14, 2018)


Annemieke has a document that is rather long and it includes a good number of hyperlinks. She would like to copy all those hyperlinks (and just the hyperlinks) to a brand-new document so that she has a list of them in one place. She wonders if there is an easy way to do this.

The only way to do this is to use a macro. (Suggestions that include using Find and Replace or finding text with specific styles will copy only the link text, not the actual hyperlink.) The key in the macro is to work with the Hyperlinks collection, paying particular attention to the TextToDisplay and Address properties of each member of the collection.

Sub PullHyperlinks()
    Dim Src As Document
    Dim Link As Hyperlink
    Dim iDoDisplay As Integer

    Set Src = ActiveDocument
    If Src.Hyperlinks.Count > 0 Then
        iDoDisplay = MsgBox("Include display text for links?", vbYesNo)

        Documents.Add DocumentType:=wdNewBlankDocument
        For Each Link In Src.Hyperlinks
            If iDoDisplay = vbYes Then
                Selection.TypeText Link.TextToDisplay
                Selection.TypeText vbTab
            End If
            Selection.TypeText Link.Address
        Next Link
        MsgBox "There are no hyperlinks in this document."
    End If
End Sub

The macro first checks to see if there are any hyperlinks in the current document. If there are, then the process of pulling them out can proceed; if there aren't, then a message is displayed to that effect.

Assuming there are hyperlinks in the document, the user is asked if the new document should contain the display text for the links. The macro then creates a new document and steps through each member of the Hyperlinks collection. The value of the TextToDisplay property is added to the new document (if appropriate) followed by the value of the Address property.


If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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

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. ...


Printing Summary Information

Word automatically maintains a number of properties for each document you create. As part of those properties you can ...

Discover More

Changing Typeface with Conditional Formatting

Conditional formatting can be a great way to modify how the information in your worksheet is displayed. The feature has ...

Discover More

Unique Military Date Format

Some industries (such as the military) have special formatting that they use to represent dates. Here is one such format ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Replacing Plain Text with a Hyperlink

Active hyperlinks can be a desired feature in some types of documents. If you want to replace multiple instances of plain ...

Discover More

Updating Document Links

If you establish dynamic links between documents, then you can force Word to update those links whenever you want. How ...

Discover More

Checking for Valid Hyperlinks

If you have a document containing a lot of hyperlinks, it would be cool if there was a way to check all those hyperlinks ...

Discover More

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

View most recent newsletter.


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}] 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 5 + 2?

2018-07-18 03:03:00


Hi Annemieke, I'm really glad to hear my solution worked for you. Regarding your question on how to have 2 columns, one with the screen text/regular text and one with the hyperlinks, my original solution would work with some extra steps.

1. Extract all the hyperlinks with my original solution and paste them in a new document.
2. Press Ctrl-A to select all the hyperlinks, and press Ctrl-Shift-F9 to "break" the hyperlinks. Now they will just be regular underlined black text.

To have a 2-column table, you could:
3. Convert the regular text into a table.
4. Add a new column.
5. Paste the extracted hyperlinks again OUTSIDE of the table. Convert the hyperlinks into a one-column table.
6. Copy the one-column table with the hyperlinks and paste it into the second column of your two-column table. The paste option that worked for me was 'Overwrite cells'.

I hope this solution is helpful!

2018-07-17 19:19:10

Ken Endacott

Here is a complete macro solution that finds hyperlinks in all parts of the document including the bibliography. It produces a tab delimited list giving the document story that contains the hyperlink, the display text, the url and the intact hyperlink. This list can be converted to a table, select the list then: Insert > the down arrow on tables > Convert Text to Table.

Sub PullAllHyperlinks()
Dim Src As Document
Dim Link As Hyperlink
Dim iDoDisplay As Integer
Dim rng As Range
Dim k As Long
Dim objSource As Source
Dim strXML As String
Dim aShape As Shape

Set Src = ActiveDocument
ActiveWindow.View.ShowFieldCodes = False

iDoDisplay = MsgBox("Include display text for links?", vbYesNo)

Documents.Add DocumentType:=wdNewBlankDocument
For Each rng In Src.StoryRanges
Call WriteHyperlinks(rng, iDoDisplay, rng.StoryType)
Select Case rng.StoryType
Case 1, 2, 3, 4, 6, 7, 8, 9, 10, 11
If rng.ShapeRange.Count > 0 Then
For Each aShape In rng.ShapeRange
If aShape.TextFrame.HasText Then
If aShape.TextFrame.TextRange.Fields.Count > 0 Then
Call WriteHyperlinks(aShape.TextFrame.TextRange, iDoDisplay, rng.StoryType)
End If
End If
Next aShape
End If
End Select
Next rng

For Each objSource In Src.Bibliography.Sources
strXML = objSource.XML
k = InStr(1, strXML, "<b:URL>")
If k > 0 Then
strXML = Mid(strXML, k + 7)
k = InStr(1, strXML, "<")
strXML = Left(strXML, k - 1)
Selection.TypeText "Bibliography" & vbTab & strXML
End If
Next objSource

End Sub

Sub WriteHyperlinks(r As Range, L As Integer, n As Long)
Dim hLink As Hyperlink
Dim storyNme()
storyNme = Array("", "Body", "Footnotes", "Endnotes", "Comments", "Text frame", "Even pages header", _
"Primary header", "Even pages footer", "Primary footer", "First page header", _
"First page footer", "", "", "", _
"", "", "")

For Each hLink In r.Hyperlinks
Selection.TypeText storyNme(n) & vbTab
If L = vbYes Then
Selection.TypeText hLink.TextToDisplay
Selection.TypeText vbTab
End If
Selection.TypeText hLink.Address & vbTab
Next hLink
End Sub

2018-07-17 11:21:42


I like Stella's approach because it a) kept the hyperlinks intact, and b) it provides me with an easy way to toggle between the text and the hyperlinks.
For my purpose: checking the hyperlinks - it works very well. It also shows me how many times I use a particular text or hyperlink, so I can use the list as a means to check x-references, logical relationships between paragraphs and generally improve the user experience.

Is there a way in which I can copy the field info - including the actual hyperlink - and paste that as regular text somewhere? That way I could create 2 columns: one with the screen text and one with the actual hyperlink (after some search and destroy).

2018-07-17 11:06:07


Great to have a solution so quickly! Thanks all for providing the main solution and the remarks.

I have tried out the macro and it creates a list alright, only the hyperlinks with me weren't hyperlinks once they were compiled into the list. They are plain text.

I tweeked the result a bit and will try to include that in the macro:
I first doubled the paragraph markers and then changed the tabs into paragraph markers, so I get:

Name / text to display

Name / text to display


I noticed that the internal hyperlinks (to other parts of the document) are empty. I resolved that by changing ^p^p^p into ^pInternal link^p^p.
That makes it a bit clearer.

Ideally the list could also show the paragraph or page number where the link appears in the list, so you'd really have a functioning register.

I'm now going to try Stella's solution :-)

2018-07-17 09:15:47

Ken Endacott

Here is a method that uses F&R to produce a comma delimited list of hyperlinks that can then be used to create a table of hyperlinks.

1. Work with a copy of the document. CTRL + A then set a font for the whole document – say Times New Roman
ALT + F9 to display field codes

Find: ^019 HYPERLINK

Replace: ^&,
Font: Arial

All of the document will now be in Times New Roman font except hyperlinks followed by a comma.

2. Use F&R to remove all characters in Times New Roman leaving a comma delimited list of hyperlinks.

Find: ?
Use Wildcards
Font: Times New Roman

Replace: leave blank and no formatting

Note that step 1 Use Wildcards is turned off but in Step 2 Use Wildcards must be on.

2018-07-17 05:19:10


Hi Ronald, thanks for your comment. Glad to know that my approach worked. I am not sure why ^19 HYPERLINK does not work for you. I did a quick Google search and found a Microsoft Community answer that suggests ^d is generic and finds any type of field - does ^d also pull out other non-hyperlink fields in your test document? I suspect ^019 HYPERLINK will find only 'hyperlink' fields.


2018-07-16 14:58:33

Ronald Bolinger

In Stella's approach I was unable to find hyperlinks by using ^019 HYPERLINK in the search. I search ^d which locates all the hyperlinks in my test document. Otherwise, her approach works perfectly.

2018-07-16 14:25:42

Ronald Bolinger

That's not true. There is a method using Find and Replace which copies the actual hyperlink.

2018-07-16 04:20:34


I have found this approach useful:

1. Press Alt-F9 to display field codes.
2. Press Ctrl-H to display 'Find and Replace' and go to the 'Find' tab (not 'Find and replace').
3. Type '^019 HYPERLINK' in the 'Find' box.
4. Click 'Find in', and in the dropdown list select 'Main document'. This will select all the hyperlinks in the document.
5. Copy and paste the hyperlinks into a new document.
6. Press Alt-F9 again in the new document to un-display the field codes and display the normal blue hyperlink text.

You said in your article that 'approaches that use Find and Replace copy only the link text, not the actual hyperlink', but my approach does copy the actual hyperlink. It preserves the display text and the hyperlink just like your macro, and I think it's simpler too.

2018-07-14 05:29:43

Ken Endacott

The macro has severe limitations. It does not detect hyperlinks in headers, footers, textboxes, bibliography, footnotes and endnotes.

Documents for publication and academic documents typically have hyperlinks in footnotes, endnotes and the bibliography. It is important that all the links are checked for validity and relevance hence a complete list of hyperlinks is a necessity.

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.

Newest Tips

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.