Some codes excerpted from the network for future use, some have been modified.
Partly from:
https://zhuanlan.zhihu.com/p/35695960
Sub sets each level of style format () With ActiveDocument.Styles (wdStyleHeading1) .Font .Color = wdColorBlack .Bold = False 'The title is no longer bold. Size = 22 ' Second number. Name = " Fangzheng Xiaobiao Song Simplified " End With With ActiveDocument.Styles (wdStyleHeading2) .Font .Color = wdColorBlack .Bold = False ' Boldface is generally no longer bold. Size = 16 ' Number three. Name = " Boldface " End With With ActiveDocument.Styles(wdStyleHeading3).Font .Color = wdColorBlack .Bold = True .Size = 16 .Name = "楷体_GB2312" End With With ActiveDocument.Styles(wdStyleHeading4).Font .Color = wdColorBlack .Bold = True .Size = 16 .Name = "仿宋_GB2312" End With With ActiveDocument.Styles(wdStyleHeading5).Font .Color =wdColorBlack .Bold = False .Size = 16 .Name = " Arial _GB2312 " End With With ActiveDocument.Styles (wdStyleNormal) .font ' disposed normal text formatting text .color = wdColorBlack .Bold = False .Size = 16 .Name = " Song-like_GB2312 " End With End Sub
Call something like
.Range.Style = wdStyleNormal ' Note: Set as a template, if you copy the content to another word, it will become the wdStyleNormal style set in the target word, which is different from the source.
But there are two drawbacks. One is that when copying the content to another word document, it will become the style set by the target word. The second is that the outline title is a bit unsuitable for official documents and other occasions (may be set to be removed, but I do n’t know).
Then manually set:
Sub sets the title format of each level (ib As Paragraph) ' Note: The title may follow the content directly without line breaks, so set the first sentence, not the entire paragraph. ' Similar to the first and second level titles If ib.Range Like " [一二 三四五 六 七八 九百 百千], * " Or ib.Range Like " [一二 三四五 六 七八九十Hundred and Thousand], *. * " Then If ib.Range.Sentences.Count = 1 Then ' ib.Range.Style = wdStyleHeading2 ib.OutlineLevel = wdOutlineLevel2 End If ' ib.Range.Font.ColorIndex = wdColorBlack ' ib.Range .Font.Bold = False ' ib.Range.Font.Size = 16 'ib.Range.Font.Name = "Bold Body " ib.Range.Sentences ( 1 ) .Font.ColorIndex = wdColorBlack ib.Range.Sentences ( 1 ) .Bold = False ' Bold body is generally no longer bold ib.Range.Sentences ( 1 ) .Font.Name = " Bold " ib.Range.Sentences ( 1 ) .Font.Size = 16 ' Similar to the first level of the three-level heading ElseIf ib.Range Like " ([1 2 3 4 5 6 7 8 Ninety-thousand thousand]) * " Then If ib.Range.Sentences.Count = 1 Then ' ib.Range.Style = wdStyleHeading3 ib.OutlineLevel =wdOutlineLevel3 End the If ib.Range.Sentences ( 1 ) .Font.ColorIndex = wdColorBlack ib.Range.Sentences ( 1 ) .Bold = True ib.Range.Sentences ( 1 ) .Font.Name = " italics _GB2312 " ib.Range .Sentences ( 1 ) .Font.Size = 16 ' Similar to 1, or 1. The four-level heading at the beginning ElseIf ib.Range Like " [0-9] [, ..] * " Then If ib.Range.Sentences.Count = 1 Then ' ib.Range.Style = wdStyleHeading4 ib.OutlineLevel =wdOutlineLevel4 End the If ib.Range.Sentences ( 1 ) .Font.ColorIndex = wdColorBlack ib.Range.Sentences ( 1 ) .Bold = True ib.Range.Sentences ( 1 ) .Font.Name = " Arial _GB2312 " ib.Range .Sentences ( 1 ) .Font.Size = 16 ' Similar to the five-level heading at the beginning of (1) ElseIf ib.Range Like " ([0-9]) * " Then If ib.Range.Sentences.Count = 1 Then ' ib .Range.Style = wdStyleHeading5 ib.OutlineLevel = wdOutlineLevel5 End If ib.Range.Sentences(1).Font.ColorIndex = wdColorBlack ib.Range.Sentences(1).Bold = True ib.Range.Sentences(1).Font.Name = "仿宋_GB2312" ib.Range.Sentences(1).Font.Size = 16 End If End Sub