|
* 昨天下午重写的全自动排序宏,适用于数字在后的情况(其实,楼主,你可以按 Alt+Shift+Up/Down来快速调整段落上下移动的)。请自行将“Answer:”改为“参考答案:”。
- Sub aaaa_Sort()
- Dim i As Paragraph, j&, s$, t$
- With Selection
- .WholeStory
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- .HomeKey 6
- Do
- Do
- .Move 4
- If .Paragraphs(1).Range.End = ActiveDocument.Content.End Then End
- Loop Until .Paragraphs(1).Range Like "A.*#?"
- Do
- .MoveEnd 4
- Loop Until .Text Like "*E.*#?"
- s = ""
- For Each i In .Paragraphs
- If i.Range Like "[A-E].*#?" Then
- s = s & i.Range.Characters.Last.Previous.Text & i.Range.Characters.First.Text
- i.Range.Characters.Last.Previous.Delete
- Else
- .Font.Color = wdColorRed
- MsgBox "Error!", 0 + 16: End
- End If
- Next
- .InsertAfter Text:=vbCr & s & vbCr
- .Paragraphs.Last.Range.Select
- t = ""
- j = 0
- Do
- j = j + 1
- t = t & .Characters(InStr(s, j) + 1)
- Loop Until j = 5
- .Text = "Answer:" & t & vbCr
- .EndKey 5
- Loop
- End With
- End Sub
复制代码 |
|