• shortcut key to goto the table of contents (Word 2002 XP SR3)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » shortcut key to goto the table of contents (Word 2002 XP SR3)

    Author
    Topic
    #439711

    Hello all

    If your working in a a long document, and for ease of navigation you want to goto the Table of contents / index, does anyone know the shortcut key?

    Many thanks in advance

    diana smile

    Viewing 2 reply threads
    Author
    Replies
    • #1051293

      There is no built-in shortcut key for this.

    • #1051337

      Hi Diana,

      Here’s a macro you could attach to a toolbar icon of keystroke combo to find a given TOC in a document:

      Sub TOCFinder()
      Dim SBar As Boolean           ' Status Bar flag
      Dim oFld As Field
      Dim i As Integer
      Dim j As Integer
      Dim k As Integer
      j = 0
      ' Store current Status Bar status, then switch on
      SBar = Application.DisplayStatusBar
      Application.DisplayStatusBar = True
      ' get the TOC to find
      k = InputBox("Which TOC # do you want to go to?", "Table of Contents Selector")
      With ActiveDocument
          For i = 1 To .Fields.Count
              If .Fields(i).Type = wdFieldTOC Then
                  j = j + 1
                  StatusBar = "TOC " & j & " of " & k & " found. Searching ..."
                  If j = k Then
                      StatusBar = "TOC " & k & " found."
                      .Fields(i).Select
                      With Selection
                      .GoTo What:=wdGoToField, Count:=i
                      .GoTo What:=wdGoToBookmark, Name:="page"
                      End With
                      Exit Sub
                  End If
              End If
          Next i
          MsgBox "TOC " & k & " not found"
      End With
      ' Clear the Status Bar
      Application.StatusBar = False
      ' Restore original Status Bar status
      Application.DisplayStatusBar = SBar
      End Sub
      

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1051349

      Here’s an alternative version of macropod’s macro that uses the built-in .TablesOfContents collection. (It may run quicker in a document with lots of other kinds of fields, although there may be a reason macropod avoided this approach, in which case I’m hoping he’ll weigh in on that issue.)

      Sub TOCFinder()
      
          Dim i As Integer
          Dim intTOCCount As Integer
      
          With ActiveDocument
              intTOCCount = .TablesOfContents.Count
              Select Case intTOCCount
               Case 0
                  MsgBox "There are no tables of contents."
                  Exit Sub
               Case 1
                  i = 1
               Case Else
                  i = InputBox("Which TOC # do you want to go to?", "TOCFinder")
                  If i > intTOCCount Then
                      MsgBox "There are only " & intTOCCount & " tables of contents."
                      i = intTOCCount
                  End If
              End Select
              .TablesOfContents(i).Range.Select
              With Selection
                  .Collapse
                  .MoveUp wdLine, 1
                  .MoveDown wdLine, 1
              End With
          End With
      End  Sub
      • #1051530

        Hi Steve,
        [indent]


        there may be a reason macropod avoided this approach


        [/indent]
        Amnesia doze

        Cheers,
        Paul Edstein
        [Fmr MS MVP - Word]

    Viewing 2 reply threads
    Reply To: shortcut key to goto the table of contents (Word 2002 XP SR3)

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

    Your information: