2 Quick Ways to Batch Extract All Hyperlinks from Your Word Document

This article is going to show you 2 quick ways to Batch extract all hyperlinks from your Word document, so as to follow the links.

Every so often, there can be hundreds of hyperlinks scattering all over a Word document. In this scenario, if you need to follow a specific link, you must navigate through the document to find it first, which can be such a pain in a long file.

However, if you export them to a new document, things can get a lot easier. Here are our solutions.

Method 1: Utilize the “Find” Feature

  1. Firstly, click “Home” tab then the arrowhead button near the “Find” command.
  2. On the drop-down menu choose “Advanced Find” to open the “Find and Replace” dialog box.Click "Home"->Click "Find"->Choose "Advanced Find"
  3. Next click “More” button and click “Format”.
  4. Choose “Style” to open “Find Style” box.
  5. Select “Hyperlink” and click “OK”.Click "Format"->Choose "Style"->Choose "Hyperlink"->Click "OK"
  6. Then click “Find In” and choose “Main Document”.Click "Find In"->Choose "Main Document"

You can see all hyperlinks in selection now. However, if you copy and paste them to a new document, you will find links lose their formatting and become plain texts.Hyperlinks lose style

Currently, Microsoft does not have a solution for this issue. So you have to convert plain texts back to hyperlinks again manually. Here is our earlier article, listing various ways you can follow: 5 Ways to Convert URL Texts to Hyperlinks in Your Word Document

Because of this shortcoming, we recommend you another way, also performed with the help of the “Find” feature. Please refer to “Find All Hyperlinks in a Document” section in this article: How to Find, Change and Delete Hyperlinks in Your Word Document

After finding all hyperlinks, you do the “Copy” and “Paste” work to export them.

Method 2: Run VBA Codes

  1. First and foremost, press “Alt+ F11” to open the VBA editor.
  2. Next click “Insert” and choose “Module” to create a new one under the “Normal” project.Click"Normal"->Click "Insert"->Click "Module"
  3. Then double click the module to open editing space and paste the bellowing codes there:
Sub ExtractAllhyperlinksInDoc()
  Dim objDoc As Document, objNewDoc As Document
  Dim objHyperlink As Hyperlink
 
  '  Initialization
  Set objDoc = ActiveDocument
  Set objNewDoc = Documents.Add
 
  '  Copy hyperlinks and paste them to a new document.
  With objDoc
    For Each objHyperlink In .Hyperlinks
      objHyperlink.Range.Copy
      objNewDoc.Activate
      With Selection
        .Paste
        .InsertParagraph
        .Collapse Direction:=wdCollapseEnd
      End With
    Next objHyperlink
  End With
End Sub
  1. Lastly, click “Run” button.Paste Codes->Click "Run"

Now there will be a new document open and all hyperlinks are clickable there.

Besides, in case there is a batch of files need to process, you can run this macro bellow:

Sub ExtractHyperlinksFromMultiDoc()
  Dim objDoc As Document, objNewDoc As Document
  Dim objHyperlink As Hyperlink
  Dim strFile As String, strFolder As String
 
  '  Initialization
  Set objNewDoc = Documents.Add
  strFolder = InputBox("Enter folder path here: ", "Folder path")
  strFile = Dir(strFolder & "\" & "*.docx", vbNormal)
 
  '  Open each file in the folder to extract hyperlinks and past them to a new document.
  While strFile <> ""
    Set objDoc = Documents.Open(FileName:=strFolder & "\" & strFile)
 
    With objDoc
      For Each objHyperlink In .Hyperlinks
        objHyperlink.Range.Copy
        objNewDoc.Activate
        With Selection
          .Paste
          .InsertParagraph
          .Collapse Direction:=wdCollapseEnd
        End With
      Next objHyperlink
    End With
    objDoc.Close
    strFile = Dir()
  Wend
End Sub

Remember to arrange all documents in one folder first. Then run the above macro to get an input box. Enter the folder path and click “OK”.Enter Folder Path->Click "OK"

All hyperlinks are now available in a new document.

Ready for Word Errors

No matter how reluctant we are to run into a Word error. It is inevitable to suffer this from time to time. Our suggestion is when Word collapses, choosing a proficient Word repair tool. Just leave everything to the professional.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xls damage and pdf repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published. Required fields are marked *