How to Delete All Hyperlinks in a MS Word Document through VBA Macro
You can delete a hyperlink in a MS Word document by right-clicking on the link and, from the pop-up menu, select Remove Hyperlink.
You can also get rid of a hyperlink by placing your cursor anywhere on the link and then pressing CTRL + SHIFT + F9.
But what if you have hundreds or thousands of hyperlinks in a Word document, spread out over hundreds or thousands of pages?
Then what do you do?
You can of course select the whole text and then press CTRL + SHIFT + F9. That will get rid of all hyperlinks in th document BUT it will get rid of all the linked FIELDS as well!
So here is a better way.
By writing a little VBA code, you can create a simple macro that would delete only the hyperlinks in the document.
(1) First open your Word document:
(2) Press ALT + F11 to display the VBA editing screen.
(3) Insert a new module by selecting Insert > Module from the menu.
(4) Type the following subprocedure code in your Code Pane:
(5) Save the code (CTRL + S). Click the GREEN RUN ARROW on the toolbar, or press F5 key, or select Run > Run Sub/User Form from the menu to run the subprocedure.
If Word displays a macro selecting dialog box, select the macro and click Run.
After you run the macro, Microsoft Word will display a text with no links, as below:
P.S. If you’d like to learn how the VBA code exactly works, please leave a comment and I’d be happy to help.
Is there any other MS Word tasks and challenges that you cannot accomplish through the normal Word controls and tools but would like to do it through VBA code? Please let me know.
(Free image courtesy of Modnar at morguefile.com)