|
本帖最后由 gwjkkkkk 于 2024-3-31 17:21 编辑
Option Explicit
Sub test()
Dim ar(), i&, j&, r&, iEnd&, strPath$
Application.ScreenUpdating = True
strPath = ThisDocument.Path & "\"
With ThisDocument.Content.Find
.ClearFormatting
.Forward = True
.Text = "[0-9]{1,}月[0-9]{1,2}日"
.MatchWildcards = True
Do While .Execute
.Parent.Select
With Selection
.MoveEndUntil Chr(13), wdForward
r = r + 1
ReDim Preserve ar(1 To 2, 1 To r)
ar(1, r) = .Range.Text
ar(2, r) = .Range.Start
End With
Loop
End With
If r Then
With ThisDocument
For j = 1 To UBound(ar, 2)
If j = UBound(ar, 2) Then iEnd = .Range.End Else iEnd = ar(2, j + 1)
.Range(ar(2, j), iEnd).Copy
With Documents.Add
Selection.Paste
.SaveAs strPath & ar(1, j)
.Close
End With
Next j
End With
End If
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|