Thanks, Greg, for the idea. Unfortunately, this does not work either: it always breaks off at toc.Update command line.
There must be something wrong but I cannot spot what is, in essence, a very simple command.
I've got around the problem by re-writing the field each time and that does the trick. Admittedly, there could be a better way but I cannot waste time in trying to resolve the problem if this solution does the trick.
This is the code that I use now:
40 If ActiveDocument.Bookmarks.Exists("ContentsTop") Then
50 ActiveDocument.Bookmarks("ContentsTop").Range.Select
60 With ActiveDocument
70 .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, LowerHeadingLevel:=6, UpperHeadingLevel:=1, IncludePageNumbers:=True, _
UseHyperlinks:=False, HidePageNumbersInWeb:=True, UseOutlineLevels:=False
80 .TablesOfContents(1).TabLeader = wdTabLeaderDots
90 .TablesOfContents.Format = wdIndexIndent
100 End With
110 End If
Every time I add a Heading 1-6 it calls this procedure and updates the TOC.
Thanks
Roderick