|
另一种代码。具有更广泛的拓展性。
Sub 提解析()
Dim isr As String
With ActiveDocument.Content
With .Find
Do While .Execute("[0-9]{1,2}.[答][案][:]*^13[【解答】]*^13", , , 1, , , 1)
n = n + 1
isr = isr & .Parent.Text
Loop
End With
Selection.HomeKey unit:=wdStory
ActiveDocument.Content.Find.Execute "[0-9]{1,2}.[答][案][:]*^13[【解答】]*^13", , , 1, , , 1, , , "", 2 '删除选项后的解析
With ActiveDocument
With .Range(.Range.End - 1, .Range.End - 1)
.InsertAfter vbCr
.InsertAfter isr
End With
End With
End With
Selection.EndKey unit:=wdStory
'删除当前行 word vba 控制光标常用代码_ssson的专栏-CSDN博客 https://blog.csdn.net/ssson/article/details/88771194
Selection.HomeKey unit:=wdLine
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.Delete
End Sub |
|