• Removing hyperlinking from TOC (Word XP)

    Author
    Topic
    #393386

    Howdy,

    Until last week I was a Word 97 user, but I’ve been upgraded to Word XP. In W97, when creating a TOC using the TOC field, ONLY the page number was hyperlinked. I’ve discovered (the hard way) that in Word XP, the entire entry (the text of the heading AND the page number) is hyperlinked. I’ve been ordered to make it behave the way it did in W97…but I’ll be hanged if I can figure out how. There doesn’t seem to be a field switch to disable this “feature”.

    Anyone got a way to make Word XP TOCs behave like W97 TOCs?

    By the way…I wish I had a monopoly like MS does so I could make arbitrary changes affecting millions of customers without having to justify them. 😉

    Thanks,

    Beej

    Viewing 5 reply threads
    Author
    Replies
    • #712902

      hi Beej,

      you can press Alt+F9 to show the field codes & delete the h switch (and the /z switch too of it’s there)
      and here’s a macro solution i wrote some time ago.

      Sub DeleteHyperLinksFromTOC_TOF()
        Dim TOC As TableOfContents
        With ActiveDocument
          For Each TOC In .TablesOfContents
            With TOC.Range
              Do Until .Hyperlinks.Count = 0
                .Hyperlinks(1).Delete
              Loop
              With .Font
                .Underline = wdUnderlineNone
                .Color = wdColorBlack
              End With
            End With
          Next
        end with
      End Sub
      
      • #712925

        Thanks for the macro; it’ll help when we get documents put together by others. Usually we use templates that include already de-hyperlinked TOC & TOF fields that only need updated after text is put into the new document — I got tired of always de-hyperlinking them, then updating the field to get rid of the hyperlinks.

      • #712926

        Thanks for the macro; it’ll help when we get documents put together by others. Usually we use templates that include already de-hyperlinked TOC & TOF fields that only need updated after text is put into the new document — I got tired of always de-hyperlinking them, then updating the field to get rid of the hyperlinks.

    • #712903

      hi Beej,

      you can press Alt+F9 to show the field codes & delete the h switch (and the /z switch too of it’s there)
      and here’s a macro solution i wrote some time ago.

      Sub DeleteHyperLinksFromTOC_TOF()
        Dim TOC As TableOfContents
        With ActiveDocument
          For Each TOC In .TablesOfContents
            With TOC.Range
              Do Until .Hyperlinks.Count = 0
                .Hyperlinks(1).Delete
              Loop
              With .Font
                .Underline = wdUnderlineNone
                .Color = wdColorBlack
              End With
            End With
          Next
        end with
      End Sub
      
    • #712992

      Hi Beej:
      The only trouble with the macro solution (& I don’t know enough about VBA to know how to overcome it) is that if you update the TOC, the h switch is still there. Try this:
      1. Show field codes (Alt+F9)
      2. Check use wildcards
      3. Find:
      ( [Tt][Oo][Cc]*)h*[!^21]
      4. Replace:
      1
      5. Select everything (Ctrl+A)
      6. Update fields (F9)

      I suppose you could record that as a macro. On second thought, you’d have to modify the macro to stop after one run or it would run infinitely. By the way, I only tested this on a couple of TOCs, so make sure you work on a copy first.

    • #712993

      Hi Beej:
      The only trouble with the macro solution (& I don’t know enough about VBA to know how to overcome it) is that if you update the TOC, the h switch is still there. Try this:
      1. Show field codes (Alt+F9)
      2. Check use wildcards
      3. Find:
      ( [Tt][Oo][Cc]*)h*[!^21]
      4. Replace:
      1
      5. Select everything (Ctrl+A)
      6. Update fields (F9)

      I suppose you could record that as a macro. On second thought, you’d have to modify the macro to stop after one run or it would run infinitely. By the way, I only tested this on a couple of TOCs, so make sure you work on a copy first.

    • #713000

      The “text” part being a hyperlink is caused by the h switch. Delete that and then update the TOC field and it should return to the old behavior. (At least, in my little test it does. smile )

      As for the changes, at least you missed the earlier move from 97 to 2000. Think of all the extra brain cells you didn’t waste. Of course, the learning curve (accidentally wrote curse the first time) is a bit steeper…

    • #713001

      The “text” part being a hyperlink is caused by the h switch. Delete that and then update the TOC field and it should return to the old behavior. (At least, in my little test it does. smile )

      As for the changes, at least you missed the earlier move from 97 to 2000. Think of all the extra brain cells you didn’t waste. Of course, the learning curve (accidentally wrote curse the first time) is a bit steeper…

    Viewing 5 reply threads
    Reply To: Removing hyperlinking from TOC (Word XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: