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 |
 
  • 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
  • fhff
    Awesome!!!!!!! saved me so much time lol thanks
  • James
    very nice! thanks for the tip!
  • Scott
    THANK YOU! 1 Million ties thank you!!
  • Umer
    Awesome work, after learning such thing, I feel like a geek ;-)
  • 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!
  • Will
    Wow, very helpful! Thank you!
  • gurinder
    thanks ...

    very very nice.. was so easy with your help

    gurinder singh
  • agun
    owo great .... thank u ...
  • Shivshanker Cheral
    you can remove hyperlink using Ctrl+6 also
  • 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!!
  • john
    Very useful to me. Thank you so much :D :D
  • 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
  • Worked like a charm for removing all hyperlinks - thanks
  • sil
    Many Thanks for this help, Muchly appreciated
  • 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
  • shabi
    it's really very good
  • Dan
    In Office 07 for words. The macro section is under the "view tab" to the far right.
  • orpheus
    Thank you very much. It's very useful.
  • tabi
    This didn't work for me...maybe a problem with Excel 2007? Or my stupidity, it's tough to say.
  • CasuaL
    Great work, thanks a lot :)
  • Bob
    Excellent - saved me having to remove 700+ hyperlinks by hand.
    Super huge thanks
  • Sridhar
    Marvellous
  • Jason
    Damn Nice!
    Thank you so much.
  • sasikanth
    it nice it working thanks
  • prasad
    very very very very very thanks
  • Johnny
    Thank you very much.
    Made my life a whole lot easier. =D
  • Anji
    THANKS that's great! Saved me precious time. Worked on my mac too.
  • k
    gr8! saves me a lot of time.
  • Andy McDandy
    Thanks a lot..great help
  • Prashanth
    just copy to notepad and paste it back!
  • adam
    I have been ALWAYS looking for this.

    Didn't know I'd ever FIND it, just by googling. Congrats. GREAT CODE!
  • ivica
    TNX
  • nox13666
    Thanks, this worked
  • vm0430
    how to enable hyperlink, after removing it using VB..?
  • 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
  • God, thank you! This is so clean and direct, without entering a bunch of dummy data to sidestep the problem. Thank you so much.
  • 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
  • Vanessa
    OMFG thx u! it works! i am soooo hppy! :D
  • rickd24
    Adding another thank you to the list!
  • senthilds08
    Very Very Thanks
  • Jay
    Thank You, this worked like a dream.
  • bninad
    dude whoever you are
    u rock
    this is excellant
  • me
    cool. never used a macro before :)
  • Si
    THANKS! This was really handy when pasting Wikipedia articles into Word
blog comments powered by Disqus