|
- Sub main()
- Dim doc As Document, Rng As Range, arr, lineCount%
- Set doc = ActiveDocument: lineCount = 40
- With doc.Content.Find
- .Text = "A.[!^13]{1,}^13^13B.[!^13]{1,}^13^13C.[!^13]{1,}^13^13D.[!^13]{1,}^13"
- .MatchWildcards = True
- Do While .Execute
- Set Rng = .Parent
- Rng.Text = Replace(Rng.Text, Chr(13) & Chr(13), Chr(13))
- If Len(Rng.Text) < lineCount Then
- Rng.MoveEnd 1, -1
- Rng.Text = Replace(Rng.Text, Chr(13), vbTab)
- If Rng.ComputeStatistics(1) > 1 Then
- doc.Undo
- End If
- ElseIf Len(Rng.Text) < lineCount * 2 Then
- arr = Split(Rng.Text, Chr(13))
- If Len(arr(0)) + Len(arr(1)) < lineCount - 2 And Len(arr(2)) + Len(arr(3)) < lineCount - 2 Then
- Rng.Text = arr(0) & vbTab & arr(1) & Chr(13) & arr(2) & vbTab & arr(3) & Chr(13)
- If Rng.ComputeStatistics(1) > 2 Then
- doc.Undo
- End If
- End If
- End If
- Rng.Move 4
- Loop
- End With
- End Sub
复制代码
拿去玩吧 |
评分
-
2
查看全部评分
-
|