Discussion Locked

Word Macro to Delete Hyperlinks

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have several Word macros that can and do delete all hyperlinks in any Word document. None provide what I am looking for. I need a Word macro that will delete all external hyperlinks leaving the text in place (but not preserving any underlines or coloring)... I also need to leave in place any hyperlinks that are internal (bookmark) hyperlinks. I want the macro to run without human intervention. No 'yes' or 'no' questions.

9 replies

by kesl

Poster rated this answer.

I have already read that complete thread. The references there and the example macros strip ALL hyperlinks. I want to strip select (external) hyperlinks leaving text.

by hal 9000

Then your only solution is to write a Macro that allows you to select what Hyperlinks to remove.

Most of the existing pieces of code are specifically written to remove [b]ALL HYPERLINKS[/b] from any document.

Col

by redddis

Probably you could easily alter one of those scripts. The only thing
you need to do is to add an extra if, which checks whether the
hyperlink is external (starts from http://). voila.

by mjhf

Here is a macro that Abigail Parker wrote for me to remove hyperlinks in the footnotes or endnotes of a Word document. See if this helps others.

Sub RemoveHyperLinksEndnotes()
'
' RemoveHyperLinksEndnotes Macro
' Macro recorded 5/20/2009 by Abigail Parker
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^e"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found Then
If ActiveWindow.ActivePane.View.Type = wdPageView Or ActiveWindow. _
ActivePane.View.Type = wdOnlineView Or ActiveWindow.ActivePane.View.Type _
= wdPrintPreview Then
ActiveWindow.View.SeekView = wdSeekEndnotes
Else
ActiveWindow.View.SplitSpecial = wdPaneEndnotes
End If
Selection.WholeStory
Dim i As Integer
For i = Selection.Hyperlinks.Count To 1 Step -1
Selection.Hyperlinks(i).Delete
Next i
' ActiveWindow.ActivePane.Close
End If
End Sub

Sub RemoveHyperLinksFootnotes()
'
' RemoveHyperLinksFootnotes Macro
' Macro recorded 5/20/2009 by Abigail Parker
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^f"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found Then
If ActiveWindow.ActivePane.View.Type = wdPageView Or ActiveWindow. _
ActivePane.View.Type = wdOnlineView Or ActiveWindow.ActivePane.View.Type _
= wdPrintPreview Then
ActiveWindow.View.SeekView = wdSeekFootnotes
Else
ActiveWindow.View.SplitSpecial = wdPaneFootnotes
End If
Selection.WholeStory
Dim i As Integer
For i = Selection.Hyperlinks.Count To 1 Step -1
Selection.Hyperlinks(i).Delete
Next i
' ActiveWindow.ActivePane.Close
End If
End Sub

This discussion is closed to new replies.