Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Macro to remove Hyperlinks

  • 30-10-2002 11:59AM
    #1
    Registered Users, Registered Users 2 Posts: 710 ✭✭✭


    Anybody good with Word macros know how to create one that will remove all hyperlinks in a document? There's way too many to remove manually.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,088 ✭✭✭BioHazRd


    Try this - I'm not sure if it's 100% effective but anyway

    Sub RemoveHyperlinks()
    Dim Hyp As Hyperlink
    For Each Hyp In ActiveDocument.Hyperlinks
    Hyp.Delete
    Next
    End Sub

    or you could try this more elaborate one

    Select text or whole document then run.

    Sub StripHyperlink()
    '
    ' StripHyperlink Macro
    ' Strip Hyperlinks from selected text
    '
    Dim i
    i = 0
    If Selection.Range.Hyperlinks.Count >= 1 Then
    While Selection.Range.Hyperlinks.Count >= 1
    For Each hLink In Selection.Hyperlinks
    hLink.Delete
    i = i + 1
    Next hLink
    Wend
    MsgBox i & " Hyperlinks have been deleted."
    Else
    MsgBox "There are no Hyperlinks in your selection"
    End If

    End Sub

    hope that helps

    Bio


  • Registered Users, Registered Users 2 Posts: 710 ✭✭✭BattlingCheese


    Thanks Bio however both those macros only remove the 1st hyperlink they encounter. Nearly there though.


  • Registered Users, Registered Users 2 Posts: 710 ✭✭✭BattlingCheese


    False alarm Bio the second one works perfectly. I ran it a second time and it detected all the hyperlinks and converted them to plain text.

    Cheers, I owe you a pint(or burdocks) at the LAN.

    Wes


Advertisement