Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

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