Thread: [Solved] Table of Contents Hyperlinks
View Single Post
 
Old 07-18-2014, 09:15 PM
macropod's Avatar
macropod macropod is online now Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,356
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

OK, so hiding the page #s isn't going to do what you need anyway.

In that case, what you probably need is a macro like the following to convert the TOC to hyperlinks. Do note, though, that hyperlinks don't update the way TOC fields do, so it's probably best to not do the conversion until the document is otherwise finalised.
Code:
Sub ConvertTOC2Hyperlinks()
Dim RngTOC As Range, RngItem As Range, StrBkMkList As String, StrTmp As String, i As Long
With ActiveDocument
  With .TablesOfContents(1)
    .Update
    For i = 2 To .Range.Fields.Count
      StrBkMkList = StrBkMkList & "|" & Split(Trim(.Range.Fields(i).Code.Text), " ")(1)
    Next
    Set RngTOC = .Range
  End With
  RngTOC.Fields.Unlink
  For i = 1 To UBound(Split(StrBkMkList, "|"))
    Set RngItem = RngTOC.Paragraphs(i).Range
    RngItem.End = RngItem.End - 1
    StrTmp = Replace(Split(StrBkMkList, "|")(i), "Toc", "HL")
    .Bookmarks.Add Name:=StrTmp, Range:=.Bookmarks(Split(StrBkMkList, "|")(i)).Range
    .Bookmarks(Split(StrBkMkList, "|")(i)).Delete
    .Hyperlinks.Add Anchor:=RngItem, SubAddress:=.Bookmarks(StrTmp).Range, _
      TextToDisplay:=.Bookmarks(StrTmp).Range.Text
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote