- Sub a720_test()
- Dim r As Range, s As Range, t As Range, i As Paragraph, j&, m&, n&
-
- ActiveDocument.Content.Find.Execute "^l", , , 0, , , , , , "^p", 2
-
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = "^13[一二三四五六七八九十百零]{1,}、*^13"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .MoveStart
- .Select
- Selection.InsertBefore Text:="BigTitle"
- .Start = .End
- End With
- Loop
- End With
-
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = "^13BigTitle[一二三四五六七八九十百零]{1,}、*^13"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .MoveStart
- .Select
- With Selection
- Do
- .MoveEnd 4
- Loop Until .Paragraphs.Last.Range Like "BigTitle*" Or .End = ActiveDocument.Content.End
- .MoveEnd 4, -1
- Set r = .Range
- For Each i In r.Paragraphs
- If Asc(i.Range) = 13 Then i.Range.Delete
- Next
-
- If .Text Like "*参考答案*" Then
- For Each i In r.Paragraphs
- If i.Range Like "#.*" Or i.Range Like "##.*" Or i.Range Like "###.*" Then
- i.Range.InsertBefore Text:="SmallTitle"
- End If
- Next
- With r
- .Find.Execute "^p", , , 0, , , , , , "`", 2
- .Find.Execute "`SmallTitle", , , 0, , , , , , "^p", 2
- .Find.Execute "`(?参考答案?)", , , 1, , , , , , "^13\1", 2
- .Characters.Last.Text = vbCr
- End With
- Do
- .MoveEnd 4, -1
- Loop Until .Paragraphs.Last.Range Like "?参考答案?" & vbCr
- .MoveEnd 4, -1
- Set s = .Range
- m = s.Paragraphs.Count
-
- Set t = ActiveDocument.Range(s.End, r.End)
- t.Select
- n = t.Paragraphs.Count
-
- If m = n Then
- For j = m To 1 Step -1
- If j > 1 Then s.Paragraphs(j).Range.Characters.Last.InsertBefore Text:="linkoutlinkout" & Replace(t.Paragraphs(j).Range.Text, vbCr, "")
- Next
- End If
- End If
- t.Delete
- End With
- .Start = .End
- End With
- Loop
- End With
- With ActiveDocument.Content.Find
- .Execute "BigTitle", , , 0, , , , , , "", 2
- .Execute "(linkoutlinkout)(*)(【答案)", , , 1, , , , , , "^13\3", 2
- .Execute "`", , , 0, , , , , , "^p", 2
- End With
- Selection.HomeKey 6
- MsgBox "Complete!", 0 + 48
- End Sub
复制代码 |