- Sub test选项互换()
- Dim i$
- With ActiveDocument
- .Content.InsertAfter Text:=vbCr
- .Select
- End With
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- With Selection
- .HomeKey Unit:=wdStory
- Do
- If .Paragraphs(1).Range Like "A.*" Then
- .Expand 4
- If MsgBox("是否处理本段?", 4 + 48) = vbNo Then GoTo sk
- sp:
- i = MsgBox("<是>:[A-B] <否>:[A-C] <取消>:[B-C]", 3 + 48, "请选择互换内容!")
- If i = vbYes Then
- .Find.Execute "(<A.)(*)([ ^s^t]{1,})(B.)(*)([ ^s^t]{1,})", , , 1, , , , , , "\1\5\3\4\2\6", 1
- ElseIf i = vbNo Then
- .Find.Execute "(<A.)(*)([ ^s^t]{1,}*)(C.)(*)(^13)", , , 1, , , , , , "\1\5\3\4\2\6", 1
- Else
- .Find.Execute "(<A.*)(B.)(*)([ ^s^t]{1,})(C.)(*)(^13)", , , 1, , , , , , "\1\2\6\4\5\3\7", 1
- End If
- .Expand 4
- If MsgBox("<是>:下一段 <否>:本段", 4 + 48, "处理段落") = vbYes Then GoTo sk Else GoTo sp
- Else
- sk:
- .Move 4
- End If
- If .Paragraphs(1).Range.End = ActiveDocument.Content.End Then Exit Do
- Loop
- End With
- ActiveDocument.Paragraphs.Last.Range.Delete
- End Sub
复制代码 |