OfficeTips Home || VBA Section || General Section ||  Download Section  ||  Privacy Policy

Clear all hyperlinks from a Word Document but retain the text
 

Documents may contain hyperlinks to other documents or Web pages on an intranet or the Internet. Hyperlinks usually appear as blue underlined text strings. In the following macro, only the link is removed. The text of the hyperlink remains in the document.


' --------------------------------------------------------------------------------
' Copyright ©1999-2018, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

Sub RemoveHyperlinks() 

Dim oStory As Range 

For Each oStory In ActiveDocument.StoryRanges 

Do While oStory.Hyperlinks.Count > 0 

oStory.Hyperlinks(1).Delete

Loop

Next oStory

End Sub


 

 


 


' --------------------------------------------------------------------------------
' Copyright ©1999-2018, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------


 

 

Copyright 1999-2018 (c) Shyam Pillai. All rights reserved.