|
* 如果不想让文字有颜色,可查找本宏代码中的 Pink粉红/Red红色/Brown褐色 三行代码,屏蔽或注释掉即可。
- Sub 第一章第一条()
- Dim i&, j$, k$, m$, n&
- k = MsgBox("<是>:第一章 <否>:第一条 <取消>:自定义", 3 + 48)
- If k = vbYes Then
- j = "章"
- ElseIf k = vbNo Then
- j = "条"
- Else
- j = InputBox("", "请输入量词(节/课/题/部分/阶段/自然段)", "部分")
- If j = "" Then End
- End If
- m = MsgBox("<是>:第一" & j & " <否>:第1" & j & " <取消>:放弃", 3 + 48)
- If m = vbYes Then
- n = 2
- ElseIf m = vbNo Then
- n = 1
- Else
- End
- End If
- With Selection
- .HomeKey Unit:=wdStory
- With .Find
- .ClearFormatting
- .Replacement.Text = ""
- Do While .Execute("^13第[一二三四五六七八九十0-90-9百零〇○Oo千]{1,}" & j, , , 1, , , 1)
- With .Parent
- If Not .Information(12) Then
- .MoveStart 1, 1
- .Expand 4
- With .Find
- .Execute " ", , , , , , , , , "", 2
- .Execute " ", , , , , , , , , "", 2
- .Execute "^s", , , , , , , , , "", 2
- .Execute "^t", , , , , , , , , "", 2
- End With
- .Characters(InStr(.Text, j) + Len(j) - 1).InsertAfter Text:=Chr(-24159)
- If j = "条" Then
- If .Text Like "*[!。:;,、!?…—.:;,!?]?" Then .Characters.Last.InsertBefore Text:="。"
- .MoveEnd 1, -(Len(.Text) - InStr(.Text, j))
- With .Font
- .NameFarEast = "黑体"
- .NameAscii = "Times New Roman"
- .Bold = True
- .Color = wdColorPink
- End With
- Else
- .Style = wdStyleSubtitle
- .Font.NameFarEast = "黑体"
- .Font.Color = wdColorRed
- If Len(j) > 1 Then .Font.Color = wdColorBrown
- If Len(j) > 1 Then .Font.Size = 18
- With .ParagraphFormat
- .SpaceBefore = 24
- .SpaceAfter = 30
- End With
- If .Text Like "*[。:;,、!?…—.:;,!?]?" Then .Characters.Last.Previous.Delete
- If .Text Like "* ???" Then .Characters.Last.Previous.InsertBefore Text:=Chr(-24159)
- .MoveEnd 1, -(Len(.Text) - (InStr(.Text, j) + Len(j) - 1))
- End If
- .MoveStart 1, 1
- .MoveEnd 1, -Len(j)
- i = i + 1
- .Text = i
- If n = 2 Then
- .Delete
- .Fields.Add Range:=.Range, Text:="= " & i & " \* CHINESENUM3"
- .Paragraphs(1).Range.Fields.Unlink
- End If
- Else
- .Tables(1).Range.Next.Select
- If Asc(.Text) <> 13 Then .InsertParagraphBefore
- .Characters(1).Font.Size = 4
- End If
- .EndKey 5
- End With
- Loop
- End With
- .HomeKey Unit:=wdStory
- End With
- End Sub
复制代码 |
|