自我解决问题,代码共享如下:
Public 次数 As Integer
Sub 删除空行通用版()
次数 = 次数 + 1
k = 次数 Mod 2 + 1
With ActiveDocument.Content '以下处理各种特殊格式
With .Find '处理答案,包括(ABCD)形式的答案,再就是答:这种形式的答案。
Do While .Execute("[\((\[【][A-D]@[\))\]】]", , , 1) '1, , , , , , "^&", 2
With .Parent
.Start = .Start + 1: .End = .End - 1
.Font.Name = "Arial Black"
.Font.ColorIndex = Choose(k, 8, 2)
.Font.Size = 18
.Collapse 0
End With
Loop
End With
With .Find
.Replacement.Font.ColorIndex = Choose(k, 8, 2)
.Replacement.Font.Underline = wdUnderlineWavy
.Replacement.Font.UnderlineColor = wdColorDarkBlue
.Execute "([修改|回答]@[::][!^13]@^13)", , , 1, , , , , , "\1", 2 '隐藏答案
.Execute "([修改|回答]@[::][!^13]@^13)", , , 1, , , , , , "\1", 2 '隐藏答案
End With
With .Find
.Replacement.Font.ColorIndex = 1
.Execute "([修改|回答]@[::])", , , 1, , , , , , "\1", 2 '显示"答案"二字。
End With
End With
End Sub |