|
Option Explicit
Sub test()
Dim ar, br(), i&, j&, iCount&, vTemp, r&
With ActiveDocument
ReDim ar(0): ar(0) = 0
With .Content.Find
.Text = "[.。]"
.Forward = True
.MatchWildcards = True
Do While .Execute
.Parent.Select
r = r + 1
ReDim Preserve ar(0 To r)
ar(r) = Selection.End
Loop
End With
r = 0
For i = 1 To UBound(ar)
.Range(ar(i - 1), ar(i)).Select
With Selection
r = r + 1
ReDim Preserve br(1 To r)
br(r) = .Range.Text
End With
Next i
For i = 1 To UBound(br) Step 2
vTemp = br(i): br(i) = br(i + 1): br(i + 1) = vTemp
Next i
.Content.Delete
With Selection
For i = 1 To UBound(br) Step 2
For j = 0 To 1
iCount = i + j
If iCount = 1 Then
.EndKey unit:=wdLine, Extend:=wdExtend
.Range.Text = br(iCount)
Else
.Collapse 0
.InsertBreak 6
.EndKey unit:=wdLine, Extend:=wdExtend
.Range.Text = br(iCount)
.Range.Font.Shading.Texture = wdTextureNone
If iCount Mod 2 = 0 Then
With .Range.Font.Shading
.Texture = wdTexture15Percent
.ForegroundPatternColor = wdColorBlack
.BackgroundPatternColor = wdColorWhite
End With
End If
End If
Next j
Next i
End With
End With
End Sub
|
|