Convert Word Hyperlink Text to URLs with VBA
Question details
Replace hyperlink display text with the actual addresses before saving a Word document as plain text.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A document contains many hyperlinks whose formatted display text needs to be converted to visible URLs for a text file.
- Observed behavior
- The hyperlinks show descriptive text rather than the web addresses needed in the text file.
Open the document in Word and check that the hyperlinks have external addresses. Enable the Developer tab in Word’s ribbon settings if it is not visible, and use macros only from sources you trust.
Replace hyperlink display text with addresses using Word VBA
Use a macro to convert external hyperlink text throughout the active document before exporting it as plain text.
The macro skips links with no external Address, such as links to locations within the same document. It also includes external file addresses, so review the results if the document contains links other than web URLs.
In Word, open the document and select Developer > Visual Basic. In the editor, select Insert > Module.
Paste this code into the module: Sub ShowHyperlinkAddresses() Dim oLink As Hyperlink Dim strAddress As String For Each oLink In ActiveDocument.Hyperlinks strAddress = oLink.Address If strAddress <> "" Then If oLink.SubAddress <> "" Then strAddress = strAddress & "#" & oLink.SubAddress End If oLink.TextToDisplay = strAddress End If Next oLink End Sub
Return to Word, select Developer > Macros, choose ShowHyperlinkAddresses, and click Run. Review the document to confirm that the visible links now show the intended addresses.
Select File > Save As, choose a location, and select Plain Text (*.txt) as the file type. Confirm the encoding if Word prompts you, then open the text file to check the URLs.

Make hyperlink addresses visible in WPS Writer
Use WPS Writer to copy each hyperlink’s address into the document text, then save a plain-text version. This manual method is most practical for a small number of links.
- 1. Open the document: Open the Word document in WPS Writer and locate a hyperlink whose address you need to show.
- 2. Copy the address: Right-click the hyperlink, choose Edit Hyperlink, and copy the URL from the address field. Close the dialog without changing the link.
- 3. Replace the display text: Select the hyperlink’s displayed text in the document and paste the copied address over it. Repeat for the other links.
- 4. Save as text: Select Menu > Save As, choose a location, and select the plain-text file type. Open the saved text file to verify the addresses.

Frequently Asked Questions
Can I keep the hyperlink text as well as the URL?
Yes. In the Word macro, replace the TextToDisplay assignment with oLink.TextToDisplay = oLink.TextToDisplay & " (" & strAddress & ")". The visible text will then be followed by the address in parentheses.
Why did the macro skip some links?
The macro skips hyperlinks whose Address property is empty. Links to headings or bookmarks within the same document may use SubAddress without an external Address.
Will hyperlinks remain active in the text file?
A plain-text file stores the visible URL as text, not as a Word hyperlink. Some applications may recognize the URL and make it clickable when you open the file.
Where can I find the Macros command in Word?
Use Developer > Macros. If the Developer tab is hidden, enable it in Word’s ribbon settings first.




