|
要求:每组必须要有空行隔开。- Private Sub 段落排序()
- Dim doc As Document, Rng As Range
- Dim Par As Paragraph
- Dim Tmp As String
- Dim n As Long
- Application.ScreenUpdating = False
- Set doc = ActiveDocument
- For Each Par In doc.Paragraphs
- If Len(Par.Range.Text) > 4 Then
- Tmp = left(Par.Range.Text, 4)
- Select Case Tmp
- Case "【省长】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".1$"
- Case "【市长】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".2$"
- Case "【县长】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".3$"
- Case "【乡长】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".4$"
- Case "【村长】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".5$"
- Case "【自己】"
- Par.Range.InsertBefore "^" & Format(n, "00000") & ".6$"
- End Select
- Else
- n = n + 1
- Par.Range.InsertBefore "^" & Format(n, "00000") & "$"
- End If
- Next
- doc.Content.Sort
- Application.ScreenUpdating = True
- End Sub
复制代码
最后自己再把序号替换掉就行了 |
|