|
- Sub test()
- '预处理
- Dim i As Paragraph, r As Range, n&
- With ActiveDocument.Content.Find
- .Execute "^13", , , 0, , , , , , "^p", 2
- .Execute "^11", , , 0, , , , , , "^p", 2
- .Parent.ListFormat.ConvertNumbersToText
- End With
- With Selection
- .WholeStory
- .ClearFormatting
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- With .Font
- .Kerning = 0
- .DisableCharacterSpaceGrid = True
- End With
- With .ParagraphFormat
- .AutoAdjustRightIndent = False
- .DisableLineHeightGrid = True
- End With
- Set r = .Range
- For Each i In r.Paragraphs
- If Asc(i.Range) = 13 Then i.Range.Delete
- Next
- End With
- '编号预处理
- With Selection
- .HomeKey unit:=wdStory
- With .Find
- .ClearFormatting
- .Replacement.Text = ""
- Do While .Execute("^13[一二三四五六七八九十0-90-9\((百零〇○Oo千]{1,}[、..\))]", , , 1, , , 1)
- With .Parent
- If .Information(12) Then .Tables(1).Range.Next.Select: .HomeKey 5
- If .Text Like "?(*" Then .Characters(2).CharacterWidth = wdWidthFullWidth
- If .Text Like "*)" Then .Characters.Last.CharacterWidth = wdWidthFullWidth
- If .Text Like "*)" Then If .Next.Text = "、" Then .Next.Delete
- If .Text Like "*[0-90-9]*" Then
- If .Text Like "?(*)" Then .MoveStart 1, 2: .MoveEnd 1, -1
- If .Text Like "*[、..]" Then .Characters.Last.Text = "."
- .Range.CharacterWidth = wdWidthHalfWidth
- End If
- .Collapse 0
- End With
- Loop
- End With
- End With
- '核心代码--颜色语句如果不喜欢,可以屏蔽/注释该行
- For Each i In ActiveDocument.Paragraphs
- If Not i.Range.Information(12) Then
- If i.Range Like "[一二三四五六七八九十百零〇○Oo千]*、*" Then
- i.Range.Font.Color = wdColorRed '红色
- n = 0
- ElseIf i.Range Like "#.*" Or i.Range Like "##.*" Or i.Range Like "###.*" Or i.Range Like "####.*" Then
- i.Range.Font.Color = wdColorBlue '蓝色
- n = n + 1
- ActiveDocument.Range(Start:=i.Range.Characters(1).Start, End:=i.Range.Characters(InStr(i.Range, ".")).End - 1).Text = n
- End If
- End If
- Next
- Selection.HomeKey 6
- End Sub
复制代码 |
|