|
* 请将代码复制到空白文档后,全选,剪切,再粘贴到 VBE 中,以防乱码。代码仅供参考!
- Sub TitleStyle999()
- Const ChnNum As String = "[一二三四五六七八九十百千零〇○Oo00Oo]@"
- Dim i As Paragraph, n&
- ActiveDocument.Content.Find.Execute "(^13第)" & ChnNum & "(章)", , , 1, , , , , , "\1一\2 ", 2
- For Each i In ActiveDocument.Paragraphs
- With i.Range
- If .Text Like "#.#.#.#.#.#.#.#.#*" Then
- .Style = wdStyleHeading9
- GoSub sk
- ElseIf .Text Like "#.#.#.#.#.#.#.#*" Then
- .Style = wdStyleHeading8
- GoSub sk
- ElseIf .Text Like "#.#.#.#.#.#.#*" Then
- .Style = wdStyleHeading7
- GoSub sk
- ElseIf .Text Like "#.#.#.#.#.#*" Then
- .Style = wdStyleHeading6
- GoSub sk
- ElseIf .Text Like "#.#.#.#.#*" Then
- .Style = wdStyleHeading5
- GoSub sk
- ElseIf .Text Like "#.#.#.#*" Then
- .Style = wdStyleHeading4
- GoSub sk
- .Font.Size = 14
- ElseIf i.Range Like "#.#.#*" Then
- .Style = wdStyleHeading3
- GoSub sk
- .Font.ColorIndex = wdGreen
- .Font.Size = 15
- ElseIf .Text Like "#.#*" Then
- .Style = wdStyleHeading2
- GoSub sk
- .Font.ColorIndex = wdPink
- .Font.Size = 16
- ElseIf .Text Like "第一章*" Then
- .Style = wdStyleHeading1
- GoSub sk
- .Font.ColorIndex = wdRed
- .Font.Size = 22
- n = n + 1
- .Characters(1).Delete
- .Characters(1).Delete
- .Fields.Add Range:=.Paragraphs(1).Range, Text:="= " & n & " \* CHINESENUM3"
- .Fields.Unlink
- .InsertBefore Text:="第"
- Else
- .Style = wdStyleNormal
- GoSub sk
- .Font.ColorIndex = wdBlue
- .Font.Size = 10.5
- End If
- End With
- Next
- Exit Sub
- sk:
- With i.Range
- With .Font
- .NameFarEast = "宋体"
- .NameAscii = "Times New Roman"
- .Size = 12
- .Bold = True
- .Color = wdColorAutomatic
- End With
- With .ParagraphFormat
- .Space2
- .LeftIndent = CentimetersToPoints(0)
- .RightIndent = CentimetersToPoints(0)
- .CharacterUnitLeftIndent = 0
- .CharacterUnitRightIndent = 0
- End With
- End With
- Return
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|