Results 1 to 6 of 6
  1. #1
    iruser
    Guest

    Hyperlinks in Word

    In Word 2000 sr 1 I have a 30 page document that has numerous hyperlinks to web pages. I want to remove all the hyperlinks. If I select all then the hyperlink feature on the insert menu does not light up as selectable. Is there a way that I can globally remove all the links?

  2. #2
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks in Word

    You're going to have to do this with code:

    Sub RemoveAllHyperlinks()

    Dim aHyperlink As Hyperlink
    For Each aHyperlink In ActiveDocument.Hyperlinks
    aHyperlink.Delete
    Next aHyperlink

    End Sub

    However, you might have to run this sub multiple times to do the trick. Due to yet another apparent Word VBA bug, this sub is only deleting half the hyperlinks each time around. Go figure.

  3. #3
    iruser
    Guest

    Re: Hyperlinks in Word

    Thanks. I had to run the macro nine times before it got them all.

    I have a nice clean document now!

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Hyperlinks in Word

    Hi Stephan,

    You're right - this is a bug. We've seen this with fields generally. Rather than use the For Each construct, the following will work to remove all of them in one pass - this approach is the way to go generally when you need to loop through the collection of fields:

    (warning: this code was typed directly in this message, it should be OK!)

    For n = ActiveDocument.Hyperlinks.Count To 1 Step -1
    ActiveDocument.Hyperlinks(n).Delete
    Next n

    Gary

  5. #5
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks in Word

    Thanks Gary for the tip.

    There's nothing more frustrating in this programming business than when you know you have all the logic right and the results still come out wrong.

    Stephan

  6. #6
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Hyperlinks in Word

    Better late than never?
    [img]/w3timages/icons/doh.gif[/img]
    Following is useful only if hyperlinks are the only page in your document. It won't hurt fields in the header or footer.
    Ctrl-A, Ctrl-F11
    Select All, Unlink Fields
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •