This simple VBA code will delete all the hyperlinks on the active document.
Reading a word document with hyperlinks, is quite annoying sometimes.
If the hyperlink is accidentally click then it will open a browser and disrupt the momentum of reading the document.
And worse if the document link, points to a malicious website then it will be another issue.
Use the VBA code below to delete all hyperlinks on a word document.
The code will also display the number of lines on the document and also the total number of hyperlinks on the document.
===============================
Sub HyperLines()
Dim nLines, i, x
Selection.WholeStory
i = Selection.Hyperlinks.Count
nLines = Selection.Range.ComputeStatistics(Statistic:=wdStatisticLines)
MsgBox "Number of Lines:" & nLines & " Number of Hyperlinks:" & i
For x = 1 To nLines
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=x
On Error Resume Next
Application.ActiveDocument.Hyperlinks(1).Delete
Next x
End Sub
===============================
Click labels below for more VBA tips..
===========================================
Educational App for Android Kids:
https://play.google.com/store/apps/details?id=com.letsmultiply
Comments
Post a Comment