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
- Firstly, click “Home” tab then the arrowhead button near the “Find” command.
- On the drop-down menu choose “Advanced Find” to open the “Find and Replace” dialog box.
- Next click “More” button and click “Format”.
- Choose “Style” to open “Find Style” box.
- Select “Hyperlink” and click “OK”.
- Then click “Find In” and 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.
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
- First and foremost, press “Alt+ F11” to open the VBA editor.
- Next click “Insert” and choose “Module” to create a new one under the “Normal” project.
- 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
- Lastly, click “Run” button.
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”.
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