Whenever I update my Table of Contents it acquires unwanted tabs, and I have to press Ctrl+Q to get rid of them

Article contributed by Dave Rado

Word does like to insert Jason tabs in a TOC for reasons which are often impossible to pin down (i.e. it's a bug). Word 97 is much more buggy that Word 2000 in this respect.

However, here are some gotchas to watch out for:

  1. Make sure you always use the From Template setting in the Insert + Index and Tables dialog (under General/Formats, on the Table of Contents tab); and define your TOC styles as appropriate.
  2. In the style definitions of your TOC styles, on the Modify Style dialog (Format + Style + Modify) – make sure you have the Automatically Update setting switched off.  (It should really be renamed Automatically screw up!).
  3. Make sure the left tab in each of your TOC styles aligns exactly with the hanging indent; and that the right tab aligns exactly with the right margin; if they don't, you'll get a Jason tab (but even if they do you might).
  4. Make sure your heading styles are tab-free – in the case of list numbered heading styles this is only possible of you define the styles programmatically – for each list level, set .TabPosition=wdUndefined.

If none of those suggestions help, try using the following macro:

Sub UpdateToc()

With ActiveDocument.TablesOfContents(1)
End With

End Sub

Either assign this macro to a keyboard shortcut or toolbar button – or you could intercept the UpdateFields, FilePrintPreview, FilePrint and FilePrintDefault commands, and put a version of the above code in each macro.

The reason I suggest including two updates in the code is that if the first update makes the TOC go onto an extra page, some of the page numbers in the TOC may become inaccurate. The second update fixes this.

Also if you're using Word 2000, note that Word 2000 insists on applying the hyperlink character style to the TOC when you update it. Goodness knows why, it doesn't display blue or underlined, but if you move your cursor into the TOC you'll see that the Hyperlink style has been applied, although its properties have not! There's no need for this – it's perfectly possible to create a ref field with a /h switch without using the Hyperlink style, and I suspect this feature was introduced by a developer with a severe hangover after a heavy weekend binge. The problem with it is that if anyone ever opens the document in Word 97, the toc will display in blue underlined text – yuk! To fix this, you could amend the above macro to include

With ActiveDocument.TablesOfContents(1)
End With