* 如果 楼主 使用 Word 2019 的话,请将代码拷贝到新建空白文档中,再全选、剪切,复制到 VBE 中执行。
- Sub a824_option()
- Dim s$, r As Range
- With ActiveDocument
- .Content.Find.Execute "^l", , , 0, , , , , , "^p", 2
- Do While .Paragraphs.Last.Range.Text = vbCr
- .Paragraphs.Last.Range.Delete
- Loop
- Set r = .Content
- sk:
- With r.Find
- .ClearFormatting
- .Text = "^13答案*^13"
- .Forward = False
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .MoveStart 1, 4
- .MoveEnd 1, -1
- If .Paragraphs.Count > 1 Then
- .MoveEnd 4, -(.Paragraphs.Count - 1)
- .MoveEnd 1, -1
- End If
- s = .Text
- .Find.Execute s, , , , , , 0
- .Expand 4
- .HighlightColorIndex = wdBrightGreen
- .End = .Start
- .SetRange Start:=0, End:=.Start
- GoTo sk
- End With
- Loop
- End With
- End With
- Selection.HomeKey 6
- End Sub
复制代码 |