Written by Allen Wyatt (last updated September 13, 2025)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365
Paul has a document that includes many hyperlinks. These are not only in the body of the document, but also in headers, footers, footnotes, and a few text boxes. He would like a way to copy the target addresses of all those hyperlinks to a new document. Paul imagines this must be done with a macro, but he doesn't know how to go about it.
There's actually a way to get hyperlinks into another document without using a macro—at least partially. You can follow these steps:
I say that this process copies hyperlinks "at least partially" because there are notable limitations to it. First, what you are copying is the hyperlink text displayed in the document, not the targets of the hyperlinks. As long as the actual URLs are displayed (when the field results are showing), then you are fine. Plus, the steps won't copy the hyperlinks targets that may be located in other areas, such as headers, footers, footnotes, etc.
Since Paul specifically said he wants the hyperlinks from wherever they may be in the document, then the best solution is to use a macro. This macro should do the job:
Sub ExtractHyperlinks()
Dim dSource As Document
Dim dTarget As Document
Dim h As Hyperlink
Dim sec As Section
Dim hdrftr As HeaderFooter
Dim shp As Shape
Dim s As Range
Dim iCount As Integer
Set dSource = ActiveDocument
Set dTarget = Documents.Add
On Error Resume Next
' --- Body, footnotes, endnotes ---
For Each s In dSource.StoryRanges
Do
For Each h In s.Hyperlinks
dTarget.Content.InsertAfter h.Address & vbCr
iCount = iCount + 1
Next h
Set s = s.NextStoryRange
Loop Until s Is Nothing
Next s
' --- Shapes / text boxes) ---
For Each shp In dSource.Shapes
If shp.TextFrame.HasText Then
For Each h In shp.TextFrame.TextRange.Hyperlinks
dTarget.Content.InsertAfter h.Address & vbCr
iCount = iCount + 1
Next h
End If
Next shp
' --- Headers/footers may contain shapes too ---
For Each sec In dSource.Sections
For Each hdrftr In sec.Headers
For Each shp In hdrftr.Shapes
If shp.TextFrame.HasText Then
For Each h In shp.TextFrame.TextRange.Hyperlinks
dTarget.Content.InsertAfter h.Address & vbCr
iCount = iCount + 1
Next h
End If
Next shp
Next hdrftr
For Each hdrftr In sec.Footers
For Each shp In hdrftr.Shapes
If shp.TextFrame.HasText Then
For Each h In shp.TextFrame.TextRange.Hyperlinks
dTarget.Content.InsertAfter h.Address & vbCr
iCount = iCount + 1
Next h
End If
Next shp
Next hdrftr
Next sec
On Error GoTo 0
MsgBox "Done! Found " & iCount & " hyperlinks."
End Sub
The macro checks everyplace that could contain hyperlinks, and then copies the target of those hyperlinks to a new document. The resulting document lists hyperlinks in no particular order, but they would be easy enough to sort, as desired.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13955) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!
Wouldn't it be great if Word allowed you to have a small pop-up that showed you some information associated with a ...
Discover MoreConvert those URLs into regular text! It's easy to do when you follow the steps in this tip.
Discover MoreWant to add a small pop-up window over a word in your document? There is no way to do this directly in Word, but you can ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments