Hi, All:
Nice to meet you all here, I have a question about the Word VBA program. How I can update my table of content, when I hide one section? I use one click code like this:
Private Sub CheckBox1_Click()
Dim Doc As Document
Set Doc = ActiveDocument
If CheckBox1.Value Then
Doc.Sections(7).Range.Font.Hidden = True
Else
Doc.Sections(7).Range.Font.Hidden = Fault
End If

Application.ScreenRefresh
End Sub
*********************************************
It can hide the section, but after I update the TOC, the format as below:
5. 33
5.1 33
5.2 33
5.3 33
5.4 33
5.5 33
5.5.1 33
5.5.2 33
5.5.3 33
6. SHREDDER SYSTEM OPERATION 33
6.1 TOPPER SHREDDER (SHREDDER 1) 33
6.1.1 JOG MODE 36
6.2 BOTTOM SHREDDER 37
6.2.1 JOG MODE 37
6.3 DIVERTER 38
6.3.1 CONTROL OPERATORS 38
6.3.2 JOG MODE 38
*****************************************
Above I use the code like this:
Sub FieldsUpdates()
Dim oStory As Range
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

Dim TOC As TableOfContents
For Each TOC In ActiveDocument.TablesOfContents
TOC.Update
Next
End Sub
********************************************************
The section already hide in the document, but my hide section TOC should also hide and header section 6 should change number to header 5, how I can do it please?
I am not a professional programmer, I am Electrical Engineer. Thanks for your help, I appreciate your time for me.