Thursday, January 18, 2007

Remove All Hyperlinks in Microsoft Word

Many a times after copying content from webpages to Microsoft Word i end up having a lot of hyperlinks. To remove the hyperlinks, manually right clicking each link and removing the link is tedious, hence i looked for a workaround to disable all links on a word document and i found this code that would help in removing all hyperlinks.

How To:

After creating the entire document go to the Visual Basic Editor in MS Word.
- Alt + F11 (opens VB Editor)

In the editor create a Macro.
- Insert- > Module

Copy the following Code.

Sub RemoveHyperlinks()
Dim varField As Field
For Each varField In ActiveDocument.Fields
If varField.Type = wdFieldHyperlink Then
varField.Unlink
End If
Next
Set varField = Nothing
End Sub

Return to MS Word
- File -> Close

This will add a Macro "RemoveAllHyperlinks". Run the Macro to remove all the hyperlinks in the current word document
- Tools -> Macro -> Run "RemoveAllHyperlinks"

7 comments:

Anonymous said...

Nice trick. Post more.

Anonymous said...

It works, but it leaves what was originally the hyperlink to be blue underlined text (still LOOKS like a hyperlink!). It would be great if I wouldn't have to go through those :)

Anonymous said...

i'm so happy about this I could cry

Naveen Reddy said...

in the if loop add varField.color and set to the color you wish. That should solve the color problem.

Anonymous said...

That is such a bloody wonderful macro. Thanks. I have clients who give me documents to work on that are riddled with hyperlinks, and I've been eliminating them by hand. Thanks!

Unknown said...

Try this - select the entire document, press CONTROL + SHIFT + F9.

Unknown said...

TO: Anonymous that posted 4 November 07 at 20:00

you casn just select all text and press ctrl+u and then change the font color to automatic (or whatever other color you want