Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I have a protected form, and I know that page numbers for the TOC sometimes
do not get updated correctly with protected forms. Does anyone have a sample macro that would work for this? I am not good with macros, so any helo would be apppreciated. Thanks, Linda. |
#2
![]() |
|||
|
|||
![]()
linda wrote:
I have a protected form, and I know that page numbers for the TOC sometimes do not get updated correctly with protected forms. Does anyone have a sample macro that would work for this? I am not good with macros, so any helo would be apppreciated. Thanks, Linda. Hi Linda, The macro needs to unprotect the document, do the update, and reprotect the document. Here's sample code: Public Sub UpdateTOC() Dim oTOC As TableOfContents Dim oldProt As WdProtectionType 'IMPORTANT: If the document protection 'includes a password, add the password 'as a parameter to the .Unprotect and '.Protect calls. 'save the existing protection type oldProt = ActiveDocument.ProtectionType If oldProt wdNoProtection Then ActiveDocument.Unprotect ' Password:="password" End If For Each oTOC In ActiveDocument.TablesOfContents oTOC.Update Next oTOC 'restore the old protection If oldProt wdNoProtection Then ActiveDocument.Protect Type:=oldProt, _ NoReset:=True ' , Password:="password" End If End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TOC page numbers not updating on locked documents | Microsoft Word Help | |||
I am having trouble with page numbers and the table of contents m. | Microsoft Word Help | |||
Word 2003 printing {PAGE} instead of page numbers | Microsoft Word Help | |||
Problem with Page Numbers in Index using Word 2002 | Microsoft Word Help | |||
Wrong Page Numbers in Table of Contents | Microsoft Word Help |