Remove All Hyperlinks in Word or Excel

Contributor Icon Contributed by katy8439 Date Icon April 3, 2006  
Tag Icon Tagged: Microsoft Office

These two nifty macros enable you to delete the embedded hyperlinks that are generated when typing URLS or copying information from the web.


Ever copy and paste something from the Internet and then into Word only to get the hyperlinks embedded? You can removed them easily with the Macros below.

Word

Hit [ALT]+[F11] to open the Visual Basic Editor

Go to “Insert” > “Module” and in the pop-up window copy:

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

Then click “File” > Close and return to Microsoft Word

You can now run the Macro in Word by going to:

Tools > Macro > Macro and then Run “RemoveAllHyperlinks”

Excel:

You can do the same in an Excel Document:

Hit [ALT]+[F11] to open the Visual Basic Editor

Go to “Insert” > “Module” and in the pop-up window copy:

Sub RemoveHyperlinks()
'Remove all hyperlinks from the active sheet
ActiveSheet.Hyperlinks.Delete
End Sub

Then click “File” > Close and return to Microsoft Excel

You can now run the Macro in Excel by going to:

Tools > Macro > Macro and then Run “RemoveAllHyperlinks”, this will delete all URLS on the selected worksheet.

Previous recipe | Next recipe |
 
  • meetmaurya
    thank you dost.
  • adam page
    Thanks for this :)
  • BentSpork
    Great code, but it doesn't go into the footnotes. here is code for footnotes using the Selection approach:

    ActiveWindow.ActivePane.View.SeekView = wdSeekFootnotes
    ' Select all text in the footnotes.
    Selection.WholeStory
    ' Loop through fields in selection.
    For Each aField In Selection.Fields
    ' If field type is a Hyperlink field.
    If aField.Type = wdFieldHyperlink Then
    aField.Unlink
    End If
    Next aField
    ' Close Footnotes and return to document
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
  • Mike
    Thanks worked great.....the first time, when i tried it a second time it went all grey, i couldnt paste the information into another word document or anything. A bit anoying :-(
  • Research
    In MS word

    select all [CTRL + A]
    then CONTROL + SHIFT + F9. ...

    NO NEED FOR VBA... Simple and fun....
  • Thanks for the info.
    Saved heaps of time and was so easy to do.
    A+
  • Jim
    My only question is, why isn't this option in the program to begin with? Answer: Microsoft.
  • shanwa
    THANK YOU X 100000000000000000000000000000000000000000000. I had over a week long work load of deleting these and this did it in seconds!!!!!!!!!!
  • Tom
    Thanks for the MS word solution. I couldn't figure out how to get rid of those stupid hyperlinks. Very greatful.
  • Tom
    Thanks for the MS word solution. I couldn't figure out how to get rid of those stupid hyperlinks. Very greatful.
  • Simplifier
    Or...select all the text and press CONTROL+6
  • amar_yadav
    I just wanted to ad something if one wants to use the same with Office 2007 or later.
    The procedure is just the same but in order to execute it we need to click on office button, then change the Popular Commands Drop Box to Macros.
    Click on the remove.....
    Add>
    Done!
  • chhenglongchhen
    i don't know delete hyperlink in Microsoft Office Word 2003
  • Very Useful Stuff :-)
  • arun_lee
    Thanks for the help. It helped me & saved my time.
  • Pirnima
    Thank You So much .. my file size has been reduced by half... Thank you really I have been looking for a solution since 3 years!!

    Is there a way where you can can keep the hyperlinks in one column that you want .. and remove it from the rest of the sheet?
  • That's strange. How do hyperlinks make your file two times bigger? Anyway to selectively remove hyperlinks, I posted the following in a previous comment (2 months ago) for Word:

    ----
    There's another tip that says to select all text and clear formatting. But this makes it lose formatting.

    I found yet another way, just select some normal text in the paragraph and click the Format Painter. Then select all the text where you want hyperlinks removed. The text retains most of the formatting (except when it disagrees with the original text selected before clicking Format Painter).
    ----

    As for Excel, you can try the second way there too! Just select a cell with normal text, then click (or double-click if you want to do multiple times) the Format Painter, then select the columns with hyperlink that you want removed. Remember that all the selected columns will have the same formatting as the original cell you selected.

    Well apparently I discovered that in both Word and Excel, it doesn't actually remove the hyperlink but only make the formatting of the link similar to the normal text you selected. This means the links no longer look like links anymore (it looks like normal text now), but when you click on it, it still launches your browser to navigate to the link address.
  • Si
    THANKS! This was really handy when pasting Wikipedia articles into Word
  • me
    cool. never used a macro before :)
  • bninad
    dude whoever you are
    u rock
    this is excellant
  • Jay
    Thank You, this worked like a dream.
  • senthilds08
    Very Very Thanks
  • rickd24
    Adding another thank you to the list!
  • Vanessa
    OMFG thx u! it works! i am soooo hppy! :D
  • There's another tip that says to select all text and clear formatting. But this makes it lose formatting.

    I found yet another way, just select some normal text in the paragraph and click the Format Painter. Then select all the text where you want hyperlinks removed. The text retains most of the formatting (except when it disagrees with the original text selected before clicking Format Painter).
  • senthilds08
    yes its also working good
    thanks dear
  • God, thank you! This is so clean and direct, without entering a bunch of dummy data to sidestep the problem. Thank you so much.
  • Kevin
    Thank you for your help. This is a command that Microsoft clearly forgot to add. Great job! Although I have written plenty of macros (mostly on Excel, but a few in Word), I was not excited about adding to my already large set of macros... but I'm glad that I did. It works perfectly!

    Thanks
  • senthilds08
    i need macro programs pls send your macros what u have.
    tks
  • vm0430
    how to enable hyperlink, after removing it using VB..?
  • nox13666
    Thanks, this worked
  • ivica
    TNX
  • adam
    I have been ALWAYS looking for this.

    Didn't know I'd ever FIND it, just by googling. Congrats. GREAT CODE!
  • Prashanth
    just copy to notepad and paste it back!
  • Andy McDandy
    Thanks a lot..great help
  • k
    gr8! saves me a lot of time.
  • Anji
    THANKS that's great! Saved me precious time. Worked on my mac too.
  • Johnny
    Thank you very much.
    Made my life a whole lot easier. =D
  • prasad
    very very very very very thanks
  • sasikanth
    it nice it working thanks
  • Jason
    Damn Nice!
    Thank you so much.
  • Sridhar
    Marvellous
  • Bob
    Excellent - saved me having to remove 700+ hyperlinks by hand.
    Super huge thanks
  • CasuaL
    Great work, thanks a lot :)
  • tabi
    This didn't work for me...maybe a problem with Excel 2007? Or my stupidity, it's tough to say.
  • orpheus
    Thank you very much. It's very useful.
  • Dan
    In Office 07 for words. The macro section is under the "view tab" to the far right.
  • shabi
    it's really very good
  • me
    ok.. it works... thanks a lot.. i've been loocking for this.. just not hard enough until now because i didn't have that much text copied.. it actually took me 2 minutes to find this... and it's great.. and u actually don't need to know anything.. just follow the easy instructions
  • sil
    Many Thanks for this help, Muchly appreciated
  • Worked like a charm for removing all hyperlinks - thanks
  • Blandoo
    Somehow this does not work for javascript embedded within a picture (buttons). Please let me know if there is a "Remove all Javascript" macro I can run.

    Thanks
  • Najen
    Hi here is code to remove all shapes which include objects ActiveX controls (Control Toolbox) or a linked or embedded OLE objects,Controls from the Forms toolbar
    ,Controls from the Drawing toolbar,Pictures, chartsactive x,buttons,pcitures,drop down lists etc.It will basically remove all these objectsActiveX controls. even cell comments but not cell comments

    Code:

    Sub Shapes1()
    'Delete all Objects except Comments
    On Error Resume Next
    ActiveSheet.DrawingObjects.Visible = True
    ActiveSheet.DrawingObjects.Delete
    On Error GoTo 0
    End Sub
  • john
    Very useful to me. Thank you so much :D :D
  • Nishant
    Hey
    I ran the above macro during a term paper that i was working on, in MS Word 2007.
    Works great - removed all the hyperlinks....
    Thanks ALOT!!
  • Shivshanker Cheral
    you can remove hyperlink using Ctrl+6 also
  • agun
    owo great .... thank u ...
  • gurinder
    thanks ...

    very very nice.. was so easy with your help

    gurinder singh
  • Will
    Wow, very helpful! Thank you!
  • Student
    Select the entire block of text, then press Ctrl-Shift-F9. Presto: No more hyperlinks. In their place, plain text.
  • Shivshanker Cheral
    Also by presssing Ctrl + 6 we can do this!
  • Umer
    Awesome work, after learning such thing, I feel like a geek ;-)
  • Scott
    THANK YOU! 1 Million ties thank you!!
  • James
    very nice! thanks for the tip!
  • fhff
    Awesome!!!!!!! saved me so much time lol thanks
  • Dehkay
    Very good.
    Have been attempting to find a solution for some time.
    This macro cleared all links in a very large file at the first attempt.
    Dehkay
blog comments powered by Disqus