TOC

  • Thread starter Thread starter Dominic
  • Start date Start date
Hi, Dominic,

Yes, you can. Right-click the TOC and click Update Field, which is the
only item on the popup menu that will be active.
 
Hi Jay,

The problem is that we have used a bookmark in a macro
that allows the user to insert new formatted pages and
have protected the document to prevent the bookmark from
being deleted. When we right click on the TOC and click
Update the new pages are not included in the TOC.
If we unprotect the document and click Update entire
table then the pagination is correct. Is there a way to
automate this?
 
This macro (which you should assign to a toolbar button in the
template) should do it. If your document has multiple sections with
only some of the sections being protected, then the macro needs to be
enhanced a bit to handle that.

Sub UpdateTOC()
Dim oTOC As TableOfContents
Dim bIsProtected As Boolean

With ActiveDocument
If .TablesOfContents.Count = 0 Then Exit Sub

bIsProtected = _
(.ProtectionType = wdAllowOnlyFormFields)
If bIsProtected Then .Unprotect

.Repaginate

For Each oTOC In .TablesOfContents
oTOC.Update
Next oTOC

If bIsProtected Then
.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
End With
End Sub
 
Back
Top