The following will unprotect a form, and update all the fields, including tables of contents
Code:
Sub UpdateAllFields()
Dim oStory As Range
Dim oTOC As TableOfContents
Dim bProtected As Boolean
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.Update
Next oTOC
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""
End If
lbl_Exit:
Exit Sub
End Sub