I have looked at your code and tested it and I cannot see anything that
should cause the problems you experience.
Does the problem occur in a single document only?
Does it make any difference if you replace the code between “With
ActiveDocument†and “End With†by the following code?
Dim oField As Field
Set oField = .Fields.Add(Range:=Selection.Range, Type:=wdFieldEmpty)
With oField
.Code.Text = "TOC \o " & Chr(34) & "1-2" & Chr(34) & " \h \z "
.Update
End With
Set oField = Nothing
The code above adds a TOC field with the field code:
TOC \o “1-2†\h \z (delete \h from the code above if you do not want the
TOC entries to work as hyperlinks)
whereas the field inserted by your code has other switches:
TOC \o “1-2†\f \z \u
The Word help tells about the \u switch: Builds a table of contents by using
the applied paragraph outline level.
Do you have TC fields in the document? (the \f switch)
Actually, I cannot tell whether it would make any difference replacing the
code but it may be worth a try.
If it does not help, you could e-mail the problem document to me (you can
extract an e-mail address from my profile). I will then have a look in order
to see whether I can find out what happens.
--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word